H-a-Neo
H-a-Neo

Reputation: 172

How to use firebase initialize with routings in Flutter

I need to initialize the Fiberbese app in a flutter routed environment

EX: I wanna use

final Future<FirebaseApp> _initialization = Firebase.initializeApp();

and after the future has completed I need to direct to the initialRoute

  initialRoute:<**Replace this with a string after future returns**>,
      routes: {
        MyHomePage.Id :(context) => MyHomePage(),
        SoundTester.Id :(context) => SoundTester(),
        GoogleMapSample.Id:(context) => GoogleMapSample()
      },

Is there any way to do this? or this is impossible to do?

Upvotes: 0

Views: 154

Answers (1)

Priyesh
Priyesh

Reputation: 1313

Initialise your app in main.dart at the main() method like this

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized(); // add this line
  await Firebase.initializeApp(); // add this line
  runApp(MyApp());
}

Upvotes: 1

Related Questions