Closed giaur500 closed 2 years ago
I know it's been a long time, but below may help you.
class MyWidget extends StatelessWidget {
Future<bool> _onWillPop() async {
return AwesomeDialog(context: context).show() as bool;
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: _onWillPop,
child: Scaffold(
backgroundColor: Colors.black,
body: Column(
children: [
],
),
),
);
}
}
I know it's been a long time, but below may help you.
class MyWidget extends StatelessWidget { Future<bool> _onWillPop() async { return AwesomeDialog(context: context).show() as bool; } @override Widget build(BuildContext context) { return WillPopScope( onWillPop: _onWillPop, child: Scaffold( backgroundColor: Colors.black, body: Column( children: [ ], ), ), ); } }
Hi, I can not use this as a return from the AwesomeDialog
var awesomeDialog = AwesomeDialog(
context: context,
headerAnimationLoop: false,
dialogType: DialogType.NO_HEADER,
title: 'Dialog Title',
desc: 'Dialog description here.............',
btnCancelOnPress: () {},
btnOkOnPress: () {},
);
var value = await awesomeDialog.show() as bool;
return value;
as it yields
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'bool' in type cast
Yo @giaur500 and @ducquynhnguyeninfo, from the version ^2.1.3
you can now pass data from the dialog using custom Navigator.pop
in the onDissmissCallback
function.
Set autoDismiss
to false
and provide onDissmissCallback
to however you want it to work
Try using this code below:
onWillPop: () async {
return await AwesomeDialog(
context: context,
dialogType: DialogType.QUESTION,
desc: 'Are you sure you want to exit the app?',
btnOkText: 'Yes',
btnOkOnPress: () {},
btnCancelText: 'No',
btnCancelOnPress: () {},
autoDismiss: false,
onDissmissCallback: (dismissType) {
Navigator.of(context).pop(dismissType == DismissType.BTN_OK);
},
).show() as bool;
}
For full working example, try this code below
@marcos930807 Please close this issue if resolved
This is how I did it with standard AlertDialog:
How to do that with AwesomeDialog? I can;t see any way to put it into showDialog. Any advice?