flutter_offline
flutter_offline copied to clipboard
wrap library whole application
is any solution to wrap the library inside whole application like MaterialApp
instead of define inside each screen and avoid extending that?
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?
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 Scaffold
with this library. you can test sample code which that's in library readme
ok thank you
@sajphon Thanks dude the solution is working very well. But there is one issue is internet connect get connect it's start from splash screen How can we Solve this issue.??? @jogboms
@sajphon Thanks dude the solution is working very well. But there is one issue is internet connect get connect it's start from splash screen How can we Solve this issue.??? @jogboms
@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 ⬆️