Now before I build my original scaffold while connection is on I need to check the server and work for it. If the server is dead I need to warn user again using InternetAddress.lookup as shown below.
final result = await InternetAddress.lookup('8.8.8.8');
My question is that, Do Flutter have InternetAddress.lookup packages or similar
to connectivity?
In below code I need to use something like appLive = 2; so I can give user a another warning that currently we are in maintenance mode.
CODE:
// TODO: 4) _MyHomePageState Class
class _MyHomePageState extends State<MyHomePage> {
var _connectionStatus = 'Unknown';
Connectivity connectivity;
StreamSubscription<ConnectivityResult> subscription;
@override
void initState() {
// TODO: implement initState
super.initState();
connectivity = new Connectivity();
subscription =
connectivity.onConnectivityChanged.listen((ConnectivityResult result) {
_connectionStatus = result.toString();
if (result == ConnectivityResult.wifi ||
result == ConnectivityResult.mobile) {
setState(() {
appLive = 1;
});
} else {
setState(() {
appLive = 0;
});
}
});
}
@override
void dispose() {
subscription.cancel();
super.dispose();
}
// TODO: BUILD WIDGET
@override
Widget build(BuildContext context) {
if (appLive == 0) {
return new Scaffold(
backgroundColor: darkMainGreen,
body: new Center(
......
// WARN USER
......
)
);
} else {
return new Scaffold(
backgroundColor: darkMainGreen,
body: new Center(
......
// SHOW ORIGINAL APPP
......
)
);
}
} // build Widget
} // _MyHomePageState Class