2

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

organicnz
  • 89
  • 1
  • 2
  • 19

5 Answers5

3

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.

PhillipJacobs
  • 2,337
  • 1
  • 16
  • 32
1

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

Abbas Jafari
  • 1,492
  • 2
  • 16
  • 28
  • 1
    He is doing it in iOs. It can be done in Xcode. For more detail : https://flutter.dev/docs/development/ui/advanced/splash-screen – Ahmet KAYGISIZ Jun 18 '21 at 12:46
  • Sorry, I forgot to mention. There's a circle progress bar on the upper left corner above the time. You can barely see it on the screenshot. For some reason it spins around and nothing happens at all. – organicnz Jun 18 '21 at 17:18
  • 1
    Ok, I need to see your home screen code, please post it. – Abbas Jafari Jun 19 '21 at 03:52
  • The home screen code is here: https://pastebin.com/8wUfJdvp. Trying to setup GitHub Actions with hidden secrets to make the repo public :) – organicnz Jun 20 '21 at 11:08
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 okay

DEMIGOD
  • 11
  • 1
0

Apologies, guys. I was fiddling with the Firestore data and didn't prepare it well enough. That's why the white screen appeared. Thank you very much for your replies!

organicnz
  • 89
  • 1
  • 2
  • 19
-1

Try to change void main to Future<void> main

Kerim
  • 558
  • 2
  • 14