i know that for back button we can do by using the willpopscope
,
but right now i' m trying to prevent user from refreshing the page, is there a way to disable the refresh button or prompt a message if user click the refresh button?
example of willpopscope
return WillPopScope (
onWillPop: () async {
return shouldPop;
},
child: const Text('WillPopScope sample'),
);
Adding this to lib/web/index.html
will display a confirmation dialog:
...
<body>
<script type="text/javascript">
window.onbeforeunload = function() {
return "Changes that you made may not be saved.";
}
</script>
...
</body>
...
Like so: