noInternetCheckView static method
dynamic
noInternetCheckView(
- Widget? viewWhenAvailable,
- dynamic controller
)
Implementation
static noInternetCheckView(Widget? viewWhenAvailable,controller){
return StreamBuilder<InternetConnectionStatus>(
stream:InternetConnectionChecker().onStatusChange,
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if(snapshot.connectionState==ConnectionState.done||snapshot.connectionState==ConnectionState.active){
if(snapshot.data==InternetConnectionStatus.connected){
return viewWhenAvailable!;
}
else if(snapshot.data==InternetConnectionStatus.disconnected){
return noInternetView(controller);
}
}
if(snapshot.connectionState==ConnectionState.waiting){
return Center(
child: CircularProgressIndicator(),
);
}
return noInternetView(controller);
}
);
}