Flutter Hardware Back Button Control

정규호·2023년 12월 9일
0

Widget build(BuildContext context) {
  return WillPopScope(
    onWillPop: () async {
      print('The user tries to pop()');
      return false;
    },
    child: Scaffold(
      appBar: AppBar(
        title: const Text("Exit app warning"),
      ),
      body: Container(),
    ),
  );
} 

return false;

출처 : Prevent back button from closing the app

profile
The Man Who Lift

0개의 댓글