title: Flutter: get default context? or load assets without context?
body: <p>I'm trying to load a json file in a class extending SearchDelegate to search through its content.</p>
  
  <p>I have a method to load this file:</p>
  
  <pre><code>Future&lt;void&gt; loadCountryData() async {
      try {
        String data = await DefaultAssetBundle
            .of(context)
            .loadString("assets/data/countries.json");
        _countries = json.decode(data);
      } catch (e) {
        print(e);
      }
  }
  </code></pre>
  
  <p>Unfortunately this requires a Buildcontext (context) that seems only to be available in the SearchDelegate build methods (like buildActions, buildLeadings, etc), but no outside like for example in the constructor.</p>
  
  <p><a href="https://docs.flutter.io/flutter/material/SearchDelegate-class.html" rel="nofollow noreferrer">https://docs.flutter.io/flutter/material/SearchDelegate-class.html</a></p>
  
  <p>As the @override xy build methods in SearchDelegate are called with every change in the search field, I would load my file over and over again, which is of course not ideal.
  I want to load my file once at the beginning only.</p>
  
  <p>Is there a way to get some sort of get default context that I could use for example in the constructor of SearchDelegate. Like in android (if I remmeber correctly)?</p>
  
  <p>Or can I load an assets file without <code>.of(context)</code>?</p>