title: Get Device Brightness when building ThemeData, outside of Material App with MediaQuery
body: <p>I want to display dark or light mode based on the settings of the device.</p>
  
  <p>I need to get the brightness of the device when building my <code>ThemeData</code>, something like this:</p>
  
  <pre><code>void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
  
    @override
    Widget build(BuildContext context) {
  
      final materialLightTheme = ThemeData(
        primaryColor: Colors.blueAccent,
        brightness: Brightness.light,
        scaffoldBackgroundColor: MyColors.backgroundColor0(Brightness.light),
        appBarTheme: AppBarTheme(
          color: MyColors.backgroundColor1(Brightness.light)
        ),
      );
  
  
      final materialDarkTheme = ThemeData(
        primaryColor: Colors.blueAccent,
        brightness: Brightness.dark,
        scaffoldBackgroundColor: MyColors.backgroundColor0(Brightness.dark),
        appBarTheme: AppBarTheme(
          color: MyColors.backgroundColor1(Brightness.dark)
        ),
      );
  
  
      Brightness brightness = MediaQuery.of(context).platformBrightness;
  
      return MaterialApp(
        themeMode: brightness == Brightness.light
          ? ThemeMode.light
          : ThemeMode.dark,
        theme: materialLightTheme,
        darkTheme: materialDarkTheme,
        home: MyHomePage(),
      );
  
    }
  }
  </code></pre>
  
  <p>But it seems, MediaQuery is not available in the build Method outside of an Material App. I get the Error </p>
  
  <blockquote>
    <p>MediaQuery.of() called with a context that does not contain a
    MediaQuery.</p>
  </blockquote>
  
  <p>How can I achieve this behaviour?</p>