title: Error: [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
body: <p>I am building a Flutter application and I have integrated Firebase, but I keep getting this error when I click on the login button. I have come across people with similar problem, but none seems to work for me. I am using VS Code as my IDE. How can I fix this problem?</p>
  <p>Here is my code for each file...</p>
  <p><strong>main.dart file</strong></p>
  <pre><code>
  import 'login_screen.dart';
  
  void main() {
    runApp(const MyApp());
  }
  
  class MyApp extends StatelessWidget {
    const MyApp({Key? key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return const MaterialApp(
        debugShowCheckedModeBanner: false,
        title: &quot;FLUTTER-FIREBASE LOGIN APP&quot;,
        home: LoginScreen(),
      );
    }
  }
  </code></pre>
  <p><strong>login_screen.dart file</strong></p>
  <pre><code>import 'package:firebase_core/firebase_core.dart';
  import 'package:flutter/material.dart';
  
  import 'profile_screen.dart';
  
  class LoginScreen extends StatefulWidget {
    const LoginScreen({Key? key}) : super(key: key);
  
    @override
    State&lt;LoginScreen&gt; createState() =&gt; _LoginScreenState();
  }
  
  class _LoginScreenState extends State&lt;LoginScreen&gt; {
    // Initialize Firebase App
    Future&lt;FirebaseApp&gt; _initializeFirebase() async {
      FirebaseApp firebaseApp = await Firebase.initializeApp();
      return firebaseApp;
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: FutureBuilder(
          future: _initializeFirebase(),
          builder: (context, snapshot) {
            if (snapshot.connectionState == ConnectionState.done) {
              return const LoginForm();
            }
            return const Center(
              child: CircularProgressIndicator(),
            );
          },
        ),
      );
    }
  }
  
  class LoginForm extends StatefulWidget {
    const LoginForm({Key? key}) : super(key: key);
  
    @override
    State&lt;LoginForm&gt; createState() =&gt; _LoginFormState();
  }
  
  class _LoginFormState extends State&lt;LoginForm&gt; {
    // Login Function
    static Future&lt;User?&gt; loginUsingEmailPassword(
        {required String email,
        required String password,
        required BuildContext context}) async {
      FirebaseAuth auth = FirebaseAuth.instance;
      User? user;
  
      try {
        UserCredential userCredential = await auth.signInWithEmailAndPassword(
          email: email, 
          password: password,
        );
        user = userCredential.user;
      } on FirebaseAuthException catch (e) {
        if (e.code == &quot;user-not-found&quot;) {
          print(&quot;No user found for that email&quot;);
        }
      }
  
      return user;
    }
  
    @override
    Widget build(BuildContext context) {
      // TextFielf Controller
      TextEditingController _emailController = TextEditingController();
      TextEditingController _passwordController = TextEditingController();
  
      return Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: &lt;Widget&gt;[
            const Text(
              &quot;MyApp Title&quot;,
              style: TextStyle(
                color: Colors.black,
                fontSize: 28,
                fontWeight: FontWeight.bold,
              ),
            ),
            const Text(
              &quot;Login to your App&quot;,
              style: TextStyle(
                color: Colors.black,
                fontSize: 44.0,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(
              height: 44.0,
            ),
            TextField(
              controller: _emailController,
              keyboardType: TextInputType.emailAddress,
              decoration: const InputDecoration(
                  hintText: &quot;enter email...&quot;,
                  prefixIcon: Icon(
                    Icons.mail,
                    color: Colors.black,
                  )),
            ),
            const SizedBox(
              height: 26.0,
            ),
            TextField(
              controller: _passwordController,
              obscureText: true,
              decoration: const InputDecoration(
                hintText: &quot;enter password...&quot;,
                prefixIcon: Icon(
                  Icons.lock,
                  color: Colors.black,
                ),
              ),
            ),
            const SizedBox(
              height: 12.0,
            ),
            const Text(
              &quot;Forgot Password?&quot;,
              style: TextStyle(
                color: Colors.blue,
              ),
            ),
            const SizedBox(
              height: 88.0,
            ),
            Container(
              width: double.infinity,
              child: RawMaterialButton(
                fillColor: const Color(0xFF0069FE),
                elevation: 0.0,
                padding: const EdgeInsets.symmetric(vertical: 20.0),
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(12.0),
                ),
                onPressed: () async {
                  User? user = await loginUsingEmailPassword(
                      email: _emailController.text,
                      password: _passwordController.text,
                      context: context);
                  print(user);
  
                  if (user != null) {
                    Navigator.of(context).pushReplacement(
                      MaterialPageRoute(builder: (context) =&gt; const ProfileScreen()));
                  }
                },
                child: const Text(
                  &quot;Login&quot;,
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 18.0,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            )
          ],
        ),
      );
    }
  }
  </code></pre>
  <p><strong>profile_screen.dart</strong></p>
  <pre><code>
  
  class ProfileScreen extends StatefulWidget {
    const ProfileScreen({ Key? key }) : super(key: key);
  
    @override
    State&lt;ProfileScreen&gt; createState() =&gt; _ProfileScreenState();
  }
  
  class _ProfileScreenState extends State&lt;ProfileScreen&gt; {
    @override
    Widget build(BuildContext context) {
      return const Scaffold(
        body: Center(
          child: Text(&quot;TO BE CONTINUED...!!!&quot;),
        ),
      );
    }
  }```
  
  
  
  **This is the error message I get when I tap on the login button**
  
  Error: [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
      at Object.throw_ [as throw] (http://localhost:51555/dart_sdk.js:5067:11)
  at firebase_core_web.FirebaseCoreWeb.new.app (http://localhost:51555/packages/firebase_core_web/firebase_core_web.dart.lib.js:285:23)
  at Function.app (http://localhost:51555/packages/firebase_core/firebase_core.dart.lib.js:111:50)
  at Function.get instance [as instance] (http://localhost:51555/packages/firebase_auth/firebase_auth.dart.lib.js:96:55)
  at loginUsingEmailPassword (http://localhost:51555/packages/flutter_login_with_firebase_authentication/login_screen.dart.lib.js:1047:47)
      at loginUsingEmailPassword.next (&lt;anonymous&gt;)
      at runBody (http://localhost:51555/dart_sdk.js:40590:34)
      at Object._async [as async] (http://localhost:51555/dart_sdk.js:40621:7)
  at Function.loginUsingEmailPassword (http://localhost:51555/packages/flutter_login_with_firebase_authentication/login_screen.dart.lib.js:1046:20)
  at http://localhost:51555/packages/flutter_login_with_firebase_authentication/login_screen.dart.lib.js:1068:66
      at Generator.next (&lt;anonymous&gt;)
      at runBody (http://localhost:51555/dart_sdk.js:40590:34)
      at Object._async [as async] (http://localhost:51555/dart_sdk.js:40621:7)
  at http://localhost:51555/packages/flutter_login_with_firebase_authentication/login_screen.dart.lib.js:1067:1029
  at ink_well._InkResponseState.new.[_handleTap] (http://localhost:51555/packages/flutter/src/material/icon_button.dart.lib.js:40468:31)
  at tap.TapGestureRecognizer.new.invokeCallback (http://localhost:51555/packages/flutter/src/gestures/recognizer.dart.lib.js:190:18)
      at LinkedMap.new.forEach (http://localhost:51555/dart_sdk.js:27679:11)
  at pointer_router.PointerRouter.new.[_dispatchEventToRoutes] (http://localhost:51555/packages/flutter/src/gestures/pointer_router.dart.lib.js:110:29)
  at pointer_router.PointerRouter.new.route (http://localhost:51555/packages/flutter/src/gestures/pointer_router.dart.lib.js:105:37)
  at binding$5.WidgetsFlutterBinding.new.handleEvent (http://localhost:51555/packages/flutter/src/gestures/binding.dart.lib.js:364:26)
  at binding$5.WidgetsFlutterBinding.new.dispatchEvent (http://localhost:51555/packages/flutter/src/gestures/binding.dart.lib.js:352:24)
  at binding$5.WidgetsFlutterBinding.new.dispatchEvent (http://localhost:51555/packages/flutter/src/rendering/layer.dart.lib.js:5427:13)
  at binding$5.WidgetsFlutterBinding.new.[_handlePointerEventImmediately] (http://localhost:51555/packages/flutter/src/gestures/binding.dart.lib.js:328:14)
  at binding$5.WidgetsFlutterBinding.new.handlePointerEvent (http://localhost:51555/packages/flutter/src/gestures/binding.dart.lib.js:302:43)
  at binding$5.WidgetsFlutterBinding.new.[_flushPointerEventQueue] (http://localhost:51555/packages/flutter/src/gestures/binding.dart.lib.js:292:14)
  at binding$5.WidgetsFlutterBinding.new.[_handlePointerDataPacket] (http://localhost:51555/packages/flutter/src/gestures/binding.dart.lib.js:283:54)
      at Object.invoke1 (http://localhost:51555/dart_sdk.js:190405:7)
      at _engine.EnginePlatformDispatcher.__.invokeOnPointerDataPacket (http://localhost:51555/dart_sdk.js:171081:15)
      at _engine.PointerBinding.__.[_onPointerData] (http://localhost:51555/dart_sdk.js:171963:49)
      at http://localhost:51555/dart_sdk.js:172401:28
      at http://localhost:51555/dart_sdk.js:172357:16
      at loggedHandler (http://localhost:51555/dart_sdk.js:172062:11)
  </code></pre>