title: Flutter: Check Internet connectivity and navigate based on output?
body: <p>I am new to flutter, I want to check whether the internet is available or not and based on the condition, the screen has to change. I have written the code below (screen switch is working properly), but I am not able to get bool output(internet). When I removed the Future in check internet class, it throws an error. Can you please solve the issue:</p>
  
  <pre><code>class _ScreenState extends State&lt;ChannelScreen&gt; {
  bool isInternet;
  bool result;
  
    @override
    void initState() {
      // TODO: implement initState
      result = check();
      super.initState();
    }
  
    @override
  
    Widget _buildChild() {
  
  
          print ("The output “);
          print (result);
         if (result != Null &amp;&amp; result == true) {
  // if internet is ON
  return Container();
                  }
  //if internet is off
         return Container();
    }
  
  
    Widget build(BuildContext context) {
      return new Container(child: _buildChild());
    }
  }
  
  
  Future&lt;bool&gt; check()   async{
    var connectivityResult =   await Connectivity().checkConnectivity();
    if (connectivityResult == ConnectivityResult.mobile) {
      print ("******* Mobile is ON ******");
      return true;
    } else if (connectivityResult == ConnectivityResult.wifi) {
      print ("******* Wifi is ON ******");
      return true;
    }
    print ("No connectivity");
    return false;
  }
  
  </code></pre>