-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
wrap library whole application #33
Comments
Yup. You use MaterialApp builder. @override
Widget build(BuildContext context) {
return new MaterialApp(
builder: (context, widget) {
return OfflineBuilder(
connectivityBuilder: (
BuildContext context,
ConnectivityResult connectivity,
Widget child,
) {
final bool connected = connectivity != ConnectivityResult.none;
if (!connected) {
return OfflineScreen();
}
return child;
},
child: widget);
},
);
} |
How could we do if we want to go deep into the app and then when the interned is disconnected then it return the no internet screen but after the internet is back we want it to stay in the same screen as the time the internet lose? |
I think for this implementation you should do it for every screen. it means you should wrap your |
ok thank you |
@MustafaDev-shaikh @Mustafa74Dev use a Stack and show your OfflineScreen on top of your main app, this way the main app stays in the tree and doesn't lose state. Stack(
children: [
MyMainApp(),
if (!connected) {
return OfflineScreen();
},
],
) Didn't test this code but this is the general idea ⬆️ |
is any solution to wrap the library inside whole application like
MaterialApp
instead of define inside each screen and avoid extending that?The text was updated successfully, but these errors were encountered: