title: Flutter create a Utility class but async function cannot be called
body: <p>My flutter app created a Utility class and would like to use the functions from utility class in different files/pages. But the the async function of Utility class cannot be called n other files. Please kindly help to solve this issue.</p>
  
  <p><a href="https://i.stack.imgur.com/dgvMN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dgvMN.png" alt="enter image description here"></a></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:connectivity/connectivity.dart';
  import 'dart:async';
  
  class Utility {
  
    ConnectivityResult connectivityResult;
  
    Future&lt;bool&gt; checkConnection() async{
      connectivityResult = await (new Connectivity().checkConnectivity());
  
      if ((connectivityResult == ConnectivityResult.mobile) || (connectivityResult == ConnectivityResult.wifi)){
        return true;
      } else {
        return false;
      }
    }
  
    static void showAlert(BuildContext context, String text) {
      var alert = new AlertDialog(
        content: Container(
          child: Row(
            children: &lt;Widget&gt;[Text(text)],
          ),
        ),
        actions: &lt;Widget&gt;[
          new FlatButton(
              onPressed: () =&gt; Navigator.pop(context),
              child: Text(
                "OK",
                style: TextStyle(color: Colors.white),
              ))
        ],
      );
  
      showDialog(
          context: context,
          builder: (_) {
            return alert;
          });
    }
  }
  </code></pre>