title: flutter shows black screen at startup after localization
body: <p>My flutter app showing a black screen for a short period of time right after the splash screen on startup after I tried localizing the app. And I am not sure where the problem is. The problem is gone when I remove the localization. The app is not crashing and the problem occurs both on debug and release mode. I saw <a href="https://stackoverflow.com/questions/59372118/black-screen-on-startup-after-updating-flutter">this solution</a> and others related to the same subject but they did not work. Deleted the app from the phones (physical &amp; emulator) then restart it but it did not work. I even created a new app and copied the Android folder over to the old project but the problem wasn't solved. I would appreciate very much if someone can help me fix it. I followed a tutorial on YouTube to do the localization. The example app also have the problem.</p>
  <pre><code>$ flutter doctor -v
  [√] Flutter (Channel stable, 1.22.6, on Microsoft Windows [Version 10.0.18363.1379], locale 
      en-US)
      • Flutter version 1.22.6 at C:\flutter
      • Framework revision 9b2d32b605 (5 weeks ago), 2021-01-22 14:36:39 -0800
      • Engine revision 2f0af37152
      • Dart version 2.10.5
  
  [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
      • Android SDK at C:\Users\masan\AppData\Local\Android\sdk
      • Platform android-30, build-tools 30.0.3
      • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
      • All Android licenses accepted.
  
  [!] Android Studio (version 4.1.0)
      • Android Studio at C:\Program Files\Android\Android Studio
      X Flutter plugin not installed; this adds Flutter specific functionality.
      X Dart plugin not installed; this adds Dart specific functionality.
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
  
  [√] VS Code (version 1.53.2)
      • VS Code at C:\Users\masan\AppData\Local\Programs\Microsoft VS Code
      • Flutter extension version 3.19.0
  
  [!] Connected device
      ! No devices available
  
  ! Doctor found issues in 2 categories.
  </code></pre>
  <p>AndroidManifest.xml</p>
  <pre><code>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.tomson.book.deputy&quot;&gt;
      &lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.READ_CONTACTS&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.WRITE_CONTACTS&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.BLUETOOTH_ADMIN&quot; /&gt;
      
      &lt;application
          android:label=&quot;Book App&quot;
          android:icon=&quot;@mipmap/ic_launcher&quot;&gt;
          &lt;activity
              android:name=&quot;.MainActivity&quot;
              android:launchMode=&quot;singleTop&quot;
              android:theme=&quot;@style/LaunchTheme&quot;
              android:configChanges=&quot;orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode&quot;
              android:hardwareAccelerated=&quot;true&quot;
              android:windowSoftInputMode=&quot;adjustResize&quot;&gt;
              &lt;meta-data
                android:name=&quot;io.flutter.embedding.android.SplashScreenDrawable&quot;
                android:resource=&quot;@drawable/launch_background&quot;
                /&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot;/&gt;
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;/&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
         
          &lt;meta-data
              android:name=&quot;flutterEmbedding&quot;
              android:value=&quot;2&quot; /&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  <p>app_localizations.dart</p>
  <pre class="lang-dart prettyprint-override"><code>import 'dart:async';
  import 'dart:convert';
  
  import 'package:flutter/material.dart';
  import 'package:flutter/services.dart';
  
  class AppLocalizations {
    final Locale locale;
    Map&lt;String, String&gt; _localizedStrings;
    AppLocalizations(this.locale);
  
    static const LocalizationsDelegate&lt;AppLocalizations&gt; delegate =
        _AppLocalizationsDelegate();
  
    ///helper method to keep the code in the widgets concise
    /////localization are accessed using an InheritedWidget 'of'
    static AppLocalizations of(BuildContext context) {
      return Localizations.of&lt;AppLocalizations&gt;(context, AppLocalizations);
    }
  
    ///load the language json file from the lang folder
    Future&lt;void&gt; load() async {
      String jsonStr =
          await rootBundle.loadString('lib/lang/${locale.languageCode}.json');
  
      Map&lt;String, dynamic&gt; jsonMap = json.decode(jsonStr);
  
      _localizedStrings = jsonMap.map((key, value) {
        return MapEntry(key, value.toString());
      });
    }
  
    ///called from every widget which needs a localized text
    String translate(String key) {
      return _localizedStrings[key];
    }
  }
  
  class _AppLocalizationsDelegate
      extends LocalizationsDelegate&lt;AppLocalizations&gt; {
    const _AppLocalizationsDelegate();
  
    @override
    bool isSupported(Locale locale) {
      return ['en', 'fr'].contains(locale.languageCode);
    }
  
    @override
    Future&lt;AppLocalizations&gt; load(Locale locale) async {
      AppLocalizations localizations = new AppLocalizations(locale);
      await localizations.load();
      return localizations;
    }
  
    @override
    bool shouldReload(_AppLocalizationsDelegate old) =&gt; false;
  }
  
  </code></pre>
  <p>main.dart</p>
  <pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';
  import 'package:flutter_localizations/flutter_localizations.dart';
  import 'package:provider/provider.dart';
  
  import 'connectivity_wrapper.dart';
  import 'l10n/app_localizations.dart';
  import 'services/app/app_properties.dart';
  import 'services/app_theme/app_theme.dart';
  import 'services/users/auth.dart';
  import 'widgets/landing/get_started.dart';
  
  //Entry point
  void main() {
    Widget _defaultHome = GetStarted();
  
    runApp(
      MainApp(
        defaultHome: _defaultHome,
        root: buildAppRoot(_defaultHome),
      ),
    );
  }
  
  ///build app root widget
  Future&lt;Widget&gt; buildAppRoot(Widget defaultHome) async {
  
    ///app default theme
    var defaultTheme;
  
    ///reload theme from prefs
    Future&lt;void&gt; reloadThemeFromPrefs() {
      debugPrint(&quot;Pulling out theme id from prefs...&quot;);
    }
  
    await reloadThemeFromPrefs();
  
    return MultiProvider(
      providers: [
        ChangeNotifierProxyProvider0&lt;AppThemeService&gt;(
          create: (_) =&gt; AppThemeService(defaultTheme),
          update: (_, prevThemeService) =&gt;
              AppThemeService(prevThemeService.currentTheme),
        ),
      ],
      child: Consumer&lt;AuthService&gt;(
        builder: (cctx, auth, _) =&gt; MaterialApp(
          key: GlobalKey(),
          //list of all supported languages
          supportedLocales: [
            Locale('en', 'US'),
            Locale('fr', 'FR'),
          ],
  
          localizationsDelegates: [
            AppLocalizations.delegate,
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
          ],
  
          localeResolutionCallback: (locales, supportedLocales) {
            for (var loc in supportedLocales) {
              if (loc.languageCode == locales.languageCode &amp;&amp;
                  loc.countryCode == locales.countryCode) {
                return loc;
              }
            }
            return supportedLocales.first;
          },
          debugShowCheckedModeBanner: false,
          title: AppProperties.appName,
          home: ConnectivityWrapper(
            child: defaultHome,
          ),
          theme: cctx.watch&lt;AppThemeService&gt;().currentTheme,
          routes: {},
        ),
      ),
    );
  }
  
  class MainApp extends StatelessWidget {
    final Widget defaultHome;
    final Future&lt;Widget&gt; root;
  
    const MainApp({
      this.defaultHome,
      this.root,
    });
  
    @override
    Widget build(BuildContext context) {
      return FutureBuilder&lt;Widget&gt;(
        future: root,
        builder: (_, snapshot) {
          if (snapshot.hasError) {
            return Text(&quot;${snapshot.error}&quot;);
          } else if (snapshot.hasData) {
            return snapshot.data;
          } else
            return Container(
              color: Color.fromRGBO(
                0,
                105,
                170,
                1,
              ),
            );
        },
      );
    }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/OOUtS.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OOUtS.gif" alt="Here is the issue" /></a></p>