title: AlertDialog without context in Flutter
body: <p>I want to show an AlertDialog when a http get fails. The function showDialog (<a href="https://api.flutter.dev/flutter/material/showDialog.html" rel="noreferrer">https://api.flutter.dev/flutter/material/showDialog.html</a>) has the parameter "@required BuildContext context", but I want to call the AlertDialog from my async function getNews(), which hasn't a context value. </p>
  
  <p>By analogy with Java, where I use null for dialog without an owner, I tried to put context value to null, but it is not accepted.</p>
  
  <p>This is my code:</p>
  
  <pre><code>  Future&lt;dynamic&gt; getNews() async {
      dynamic retVal;
      try {
        var response = await http.get(url));
        if (response.statusCode == HttpStatus.ok) {
          retVal = jsonDecode(response.body);
        }
      } catch (e) {
        alertDlg(?????????, 'Error', e.toString());
    }
      return
      retVal;
    }
  
    static Future&lt;void&gt; alertDlg(context, String titolo, String messaggio) async {
      return showDialog&lt;void&gt;(
          context: context,
          barrierDismissible: false, // user must tap button!
          builder: (BuildContext context) {
          return AlertDialog(
                title: Text(titolo),
          ...
      );
    }
  </code></pre>