diff --git a/lib/login.dart b/lib/login.dart new file mode 100644 index 0000000..477ed26 --- /dev/null +++ b/lib/login.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; + +// Import the firebase_core plugin +import 'package:firebase_core/firebase_core.dart'; + +void main() { + WidgetsFlutterBinding.ensureInitialized(); + runApp(App()); +} + +class App extends StatefulWidget { + _AppState createState() => _AppState(); +} + +class _AppState extends State { + // Set default `_initialized` and `_error` state to false + bool _initialized = false; + bool _error = false; + + // Define an async function to initialize FlutterFire + void initializeFlutterFire() async { + try { + // Wait for Firebase to initialize and set `_initialized` state to true + await Firebase.initializeApp(); + setState(() { + _initialized = true; + }); + } catch(e) { + // Set `_error` state to true if Firebase initialization fails + setState(() { + _error = true; + }); + } + } + + @override + void initState() { + initializeFlutterFire(); + super.initState(); + } + + @override + Widget build(BuildContext context) { + //Show error message if initialization failed + // if(_error) { + // return SomethingWentWrong(); + // } + // + // // Show a loader until FlutterFire is initialized + // if (!_initialized) { + // return Loading(); + // } + + return App(); + } +} \ No newline at end of file