'White blank screen is displayed when I run my flutter app

I've already added a few dart files with Firebase integration and fixed deprications, but unfortunately it shows a white blank screen when I run my flutter app on both iOS and Android. Is there a way I could fix it? :)

main.dart

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:foodshare/screens/home_page.dart';
// import 'package:foodshare/screens/home_screen.dart';
import 'package:foodshare/screens/login.dart';
import 'package:foodshare/screens/signup.dart';
import 'package:foodshare/screens/start.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Foodshare App',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primaryColor: Colors.yellow.shade800,
        accentColor: Color(0xFFFEF9EB),
      ),
      home: HomePage(),
      routes: <String, WidgetBuilder>{
        "Login": (BuildContext context) => Login(),
        "SignUp": (BuildContext context) => SignUp(),
        "Start": (BuildContext context) => Start(),
      },
    );
  }
}

enter image description here



Solution 1:[1]

If you're using Firebase, then it's a problem with await Firebase.initializeApp();. Try remove it and it should work. Yes your app will error but then put it back and you should be sorted.

Solution 2:[2]

It can be have lots of reason,

1)Please make sure that your package_name is the same in all files (like google-services.json, AndroidManifest in the debug and main and ...).

2)If you see the black window background of the activity showing until Flutter renders its first frame, add this on your AndroidManifest, between < activity> ... < /activity>

<meta-data
       android:name="io.flutter.embedding.android.SplashScreenDrawable"
   android:resource="@drawable/launch_background"
/>

And please refer to these links for other reason:

Why is my flutter app not displaying anything but a blank screen?

Flutter app on start it is showing white screen for few second

Only blank white screen is displayed when i run my flutter app

Solution 3:[3]

Try to change void main to Future<void> main

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PhillipJacobs
Solution 2 Abbas Jafari
Solution 3 Kerim