🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / FLUTTER / geri gelmeden önce çalışan metot

1-) FLUTTER - geri gelmeden önce çalışan metot

 

automaticallyImplyLeading: false ise geri buttonu vardır ve WillPopScope bu buttona basılınca geri gelmeden önce çalışır.

Future.value(false) yaparsan geri gitmez ama true yaparsan gider

 

 ÖRNEK

 

return WillPopScope(
  onWillPop: () {
    showDialog(
        barrierDismissible:
false, // boşluğa tıklasa bile kapatmaz.
        
context: context,
        builder: (contex) {
          
return AlertDialog(
            title:
Text("Çıkmak istediğine emin misin ?"),
            actions: [
              
ElevatedButton(
                  onPressed: () {
                    
Navigator.pop(context);
                  },
                  child:
Text("İPTAL")),
              
ElevatedButton(
                  onPressed: () {
                    
Navigator.pop(context);
                    
Navigator.pop(context);
                  },
                  child:
Text("EVET"))
            ],
          );
        });

    
return Future.value(false);
  },

 

 

 Widget build(BuildContext context) {

    return WillPopScope(

 

 

 2022 Eylül 03 Cumartesi
 388