getWidgetBasedInResult function

Widget getWidgetBasedInResult(
  1. ConnectivityResult _connectivityResult,
  2. Widget? wifiWidget,
  3. Widget? mobileWidget,
  4. Widget? noneWidget,
)

Choose what widget will be shown based in network state.

Implementation

Widget getWidgetBasedInResult(ConnectivityResult _connectivityResult,
    Widget? wifiWidget, Widget? mobileWidget, Widget? noneWidget) {
  switch (_connectivityResult.index) {
    case 0:
      return wifiWidget ?? OnWifiWidget();
    case 1:
      return mobileWidget ?? OnMobileWidget();
    case 2:
      return noneWidget ?? OnNoneWidget();
    default:
      throw FlutterError("CoonnectivityResult returned nonexistent value\n"
          "Report this issue on [on_connectivity_widget] Github.");
  }
}