WillPopScope


...
return WillPopScope(  
  onWillPop: () async {
    return await Get.defaultDialog(
      title: 'Keluar aplikasi',
      content: Text('Anda yakin?'),
      confirm: ElevatedButton(
          onPressed: () {
            Get.back(result: true);
          },
          child: Text('Keluar')),
      cancel: ElevatedButton(
          style: ElevatedButton.styleFrom(
            primary: Colors.grey,
          ),
          onPressed: () {
            Get.back(result: false);
          },
          child: Text('Batal')),
    );
  },
  child:  // your child

Last updated