title: Flutter bloc and null safety implementation
body: <p>I'm implementing Null Safety to Bloc Patter in flutter, everything was ok, but when I tried to instance bloc in my widgets, I got an error &quot;Null check operator used on a null value&quot;
  The error cames from this section on my bloc event</p>
  <pre><code>class LoginEvent extends InheritedWidget{
    final LoginBloc loginBloc = LoginBloc();
  
    LoginEvent({required Widget child}) : super(child: child);
    // This function has the error
    static LoginBloc of(BuildContext context){
      return context.dependOnInheritedWidgetOfExactType&lt;LoginEvent&gt;()!.loginBloc;
    }
  
    @override
    bool updateShouldNotify(covariant InheritedWidget oldWidget) =&gt; true;
  }
  </code></pre>
  <p>If I delete the '!' the message that appears is &quot;The property 'loginBloc' can't be unconditionally accessed because the receiver can be 'null'.&quot;</p>
  <p>This is my bloc class</p>
  <pre><code>class LoginBloc with LoginState{
    final _emailController = BehaviorSubject&lt;String&gt;();
    final _passwordController = BehaviorSubject&lt;String&gt;();
  
    Stream&lt;String&gt;get emailStream =&gt; _emailController.stream.transform(checkEmail);
    Stream&lt;String&gt;get passwordStream =&gt; _passwordController.stream.transform(checkEmail);
  
    Stream&lt;bool&gt; get formValidStream =&gt; Rx.combineLatest2(emailStream,passwordStream, (e,p) =&gt; true);
  
    Function(String) get changeEmail =&gt; _emailController.sink.add;
    Function(String) get changePassword =&gt; _passwordController.sink.add;
  
    String get email =&gt; _emailController.value;
    String get password =&gt; _passwordController.value;
  
    dispose(){
      _emailController.close();
      _passwordController.close();
    }
  }
  </code></pre>
  <p>Fast preview of how it is called</p>
  <pre><code>  @override
    Widget build(BuildContext context) {
      var height =
          MediaQuery.of(context).size.height - MediaQuery.of(context).padding.top;
      var space = height &gt; 650 ? DesignSpacings.spaceM : DesignSpacings.spaceS;
      
      final bloc = LoginEvent.of(context); // if this line is commented the app shows the widget again
  
      return Card(...);
    }
  </code></pre>