title: i've been getting "null check opreator used on a null value"
body: <p>i've been getting error &quot;null chack opreator used on a null value&quot;
  whenever im trying to pull value from my firestore database using provider and change notifier</p>
  <p>here's my user_provider.dart</p>
  <pre><code>    import 'package:flutter/widgets.dart';
      import 'package:test_app/models/user.dart';
      import 'package:test_app/resources/auth_methods.dart';
      
      class UserProvider with ChangeNotifier {
        User? _user;
        final AuthMethods _authMethods = AuthMethods();
      
        User get getUser =&gt; _user!;
      
        Future&lt;void&gt; refreshUser() async {
          User user = await _authMethods.getUserDetails();
          _user = user;
          notifyListeners();
        }
      }
  </code></pre>
  <p>and here's my home.dart where im pulling data from firestore</p>
  <pre><code>    import 'package:bottom_navy_bar/bottom_navy_bar.dart';
      import 'package:cloud_firestore/cloud_firestore.dart';
      import 'package:firebase_auth/firebase_auth.dart';
      import 'package:flutter/material.dart';
      import 'package:provider/provider.dart';
      import 'package:test_app/components/background.dart';
      import 'package:test_app/providers/user_provider.dart';
      import 'package:test_app/models/user.dart' as model;
      
      // import 'dart:html';
      
      class Home extends StatefulWidget {
        const Home({Key? key}) : super(key: key);
      
        @override
        State&lt;Home&gt; createState() =&gt; _HomeState();
      }
      
      class _HomeState extends State&lt;Home&gt; {
        @override
        void initState() {
          super.initState();
          addData();
        }
      
        addData() async {
          UserProvider _userProvider =
              Provider.of&lt;UserProvider&gt;(context, listen: false);
          await _userProvider.refreshUser();
        }
      
        @override
        Widget build(BuildContext context) {
          model.User? user = Provider.of&lt;UserProvider&gt;(context).getUser;
          
          return Scaffold(body: Text(user.email),);
        }
      }
  </code></pre>
  <p>here's my main.dart for incase</p>
  <pre><code>import 'dart:ffi';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:firebase_core/firebase_core.dart';
  import 'package:flutter/material.dart';
  import 'package:provider/provider.dart';
  import 'package:test_app/pages/home.dart';
  import 'package:test_app/pages/login.dart';
  import 'package:google_fonts/google_fonts.dart';
  import 'package:test_app/pages/signup.dart';
  import 'package:test_app/providers/user_provider.dart';
  import 'package:test_app/utilis/routes.dart';
  
  void main() async {
    // ignore: prefer_const_constructors
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp();
    runApp(MyApp());
  }
  
  class MyApp extends StatelessWidget {
    const MyApp({Key? key}) : super(key: key);
    @override
    Widget build(BuildContext context) {
      return MultiProvider(
        providers: [
          ChangeNotifierProvider(
            create: (_) =&gt; UserProvider(),
          )
        ],
        child: MaterialApp(
            // home: Home(),
            debugShowCheckedModeBanner: false,
            themeMode: ThemeMode.dark,
            darkTheme: ThemeData(brightness: Brightness.light),
            theme: ThemeData(
                primarySwatch: Colors.deepPurple,
                fontFamily: GoogleFonts.mcLaren().fontFamily,
                appBarTheme: AppBarTheme(
                  color: Colors.white,
                  elevation: 0.0,
                  iconTheme: IconThemeData(color: Colors.black),
                )),
            // ignore: prefer_const_constructors
            home: StreamBuilder(
                stream: FirebaseAuth.instance.authStateChanges(),
                builder: (context, snapshot) {
                  if (snapshot.connectionState == ConnectionState.active) {
                    // Checking if the snapshot has any data or not
                    if (snapshot.hasData) {
                      // if snapshot has data which means user is logged in then we check the width of screen and accordingly display the screen layout
                      return const Home();
                    } else if (snapshot.hasError) {
                      return const Login();
                    }
                  }
  
                  // means connection to future hasnt been made yet
                  if (snapshot.connectionState == ConnectionState.waiting) {
                    return const Center(
                      child: CircularProgressIndicator(),
                    );
                  }
                  return const Login();
                })),
      );
    }
  }
  </code></pre>
  <p>my debug console</p>
  <pre><code>══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY 
  
  ╞═══════════════════════════════════════════════════════════
  The following _CastError was thrown building Home(dirty, dependencies:
  [_InheritedProviderScope&lt;UserProvider?&gt;], state: _HomeState#17895):
  Null check operator used on a null value
  
  The relevant error-causing widget was:
    Home Home:file:///C:/Users/abc/Desktop/flutter/test_app/lib/main.dart:53:34
  
  When the exception was thrown, this was the stack:
  #0      UserProvider.getUser (package:test_app/providers/user_provider.dart:9:28)
  #1      _HomeState.build (package:test_app/pages/home.dart:36:59)
  #2      StatefulElement.build (package:flutter/src/widgets/framework.dart:4870:27)
  #3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4754:15)
  #4      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
  #5      Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
  #6      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4735:5)
  #7      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4919:11)
  #8      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4729:5)
  #9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3790:14)
  #10     Element.updateChild (package:flutter/src/widgets/framework.dart:3524:20)
  #11     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
  #12     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
  #13     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
  #14     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2659:19)
  #15     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:882:21)
  #16     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
  #17     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
  #18     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
  #19     SchedulerBinding.scheduleWarmUpFrame.&lt;anonymous closure&gt; (package:flutter/src/scheduler/binding.dart:862:7)
  (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
  </code></pre>
  <p>my app runs fine but before opnening it shows a redscreen with the error null check opreator used on a null value and after a sec it goes out and it keep working the same but debug shows me the following error in debugconsole</p>