-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flushbar without context #136
Comments
You can't. Flushbar needs a context to push itself into the route stack |
In first route, when we navigate to second route, we have a background task, the task may fail, I want to show a message to end user by flush bar, UI is in SecondRoute (or may be another route) and In FirstRoute after (or before , no matter) navigation, background task runned and after a while may be failed import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: 'Navigation Basics',
home: FirstRoute(),
));
}
class FirstRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('First Route'),
),
body: Center(
child: RaisedButton(
child: Text('Open route'),
onPressed: () async {
await Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
Flushbar(
title: "Hey Ninja",
message:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry",
duration: Duration(seconds: 3),
)..show(context);
},
),
),
);
}
}
class SecondRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Second Route"),
),
body: Center(
child: Text(
"I want to show here Flushbar, Flushbar.show called in FirstRoute"),
),
);
}
} |
If we don't use context it will be much more convenient. |
How can I show flushbar without context?
The text was updated successfully, but these errors were encountered: