Home > Software engineering >  flutter :How to close a gify dialog
flutter :How to close a gify dialog

Time:06-21

showDialog( context: context,builder: (_) => NetworkGiffyDialog( image: Image.asset('asset/gif/send.gif'), title: const Text('Send Money', textAlign: TextAlign.center, style: TextStyle( fontSize: 22.0, fontWeight: FontWeight.w600)), description:const Text('Are you sure you want to Send this Amount?', textAlign: TextAlign.center, ), entryAnimation: EntryAnimation.BOTTOM, onOkButtonPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => const HomePage())); Fluttertoast.showToast(msg: "Sent with Success");

                         },

CodePudding user response:

Instead of Navigator.push(...), just use Navigator.pop(context, result) on the NetworkGiffyDialog.onOkButtonPressed and/or NetworkGiffyDialog.onCancelButtonPressed events. Where the result can be a boolean that says if the user did tap on Cancel or OK button. It should close the dialog displayed by the showDialog function

CodePudding user response:

just like onOkButtonPressed, add onCancelButtonPressed inside NetworkGifyDialog, also add buttonCancelText for text.

buttonCancelText: Text('cancel'),
//dismiss the dialog.
onCancelButtonPressed:()
{
Navigator.pop(context);
}


showDialog(
                      context: context,
                      builder: (_) => NetworkGiffyDialog(
                            key: keys[1],
                            image: Image.network(
                              "https://raw.githubusercontent.com/Shashank02051997/FancyGifDialog-Android/master/GIF's/gif14.gif",
                              fit: BoxFit.cover,
                            ),
                            entryAnimation: EntryAnimation.TOP_LEFT,
                            title: Text(
                              'Granny Eating Chocolate',
                              textAlign: TextAlign.center,
                              style: TextStyle(
                                  fontSize: 22.0, fontWeight: FontWeight.w600),
                            ),
                            description: Text(
                              'This is a granny eating chocolate dialog box. This library helps you easily create fancy giffy dialog.',
                              textAlign: TextAlign.center,
                            ),
                            onOkButtonPressed: () {},
//dismiss the dialog.
onCancelButtonPressed:()
{
Navigator.pop(context);
}
                          ));
                }),


  • Related