Closed thefirebanks closed 1 year ago
UPDATE: Solved it by adding a late
modifier to flush:
late Flushbar flush;
flush = Flushbar<bool>(
title: notificationTitle,
message: notificationMessage,
flushbarPosition: FlushbarPosition.TOP,
flushbarStyle: FlushbarStyle.FLOATING,
duration: Duration(seconds: 5),
mainButton: TextButton(
child: Text(
"Dismiss",
style: TextStyle(color: Colors.amber),
),
onPressed: () {
flush.dismiss(true);
},
),
);
flush.show(context);
But I'll keep this here in case anyone else runs into a similar issue
finally found the solution!!! Big thanks
Describe the bug Trying to create a Flushbar that gets dismissed when the user presses a button following the example here, but 2 issues come up:
FlatButton
widget is deprecated (so I'm using aTextButton
instead)The non-nullable local variable 'flush' must be assigned before it can be used. Try giving it an initializer expression, or ensure that it's assigned on every execution path.
To Reproduce Steps to reproduce the behavior:
This is my current code:
Which doesn't fully build because of the error, so I can't initialize the app.
Expected behavior The app should initialize and the button should be created.
Smartphone (please complete the following information):