title: Flutter: Dart Convert properly null safety my class
body: <p>How to change my class for null safety compliant?</p>
  <p>My error for converting my project to null safety.</p>
  <ul>
  <li><p>error • The parameter '<code>bloc</code>' can't have a value of 'null' because of
  its type, but the implicit default value is 'null' at
  <code>lib/blocs/bloc_provider.dart:10:32</code> •
  (<code>missing_default_value_for_parameter</code>)</p>
  </li>
  <li><p>error • The parameter 'child'    can't have a value of 'null' because
  of its type, but the implicit    default value is 'null' at
  <code>lib/blocs/bloc_provider.dart:10:53</code> •<br />
  (<code>missing_default_value_for_parameter</code>)</p>
  </li>
  <li><p>error • A value of type '<code>BlocProvider&lt;T&gt;</code>?' can't be assigned to a
  variable of type '<code>BlocProvider&lt;T&gt;</code>' at
  <code>lib/blocs/bloc_provider.dart:14:9</code> • (<code>invalid_assignment</code>)   error •
  The property '<code>length</code>' can't be unconditionally accessed because the
  receiver can be '<code>null</code>' at
  <code>lib/ui/login/components/sponsors_stagiaire_tab.dart:147:28</code> •
  (<code>unchecked_use_of_nullable_value</code>)</p>
  </li>
  </ul>
  <pre><code>import 'package:flutter/cupertino.dart';
  
  import 'blocs.dart';
  
  class BlocProvider&lt;T extends Bloc&gt; extends StatefulWidget {
    final T bloc;
  
    final Widget child;
  
    BlocProvider({@required this.bloc, @required this.child});
  
    static T of&lt;T extends Bloc&gt;(BuildContext context) {
      final BlocProvider&lt;T&gt; _provider =
          context.findAncestorWidgetOfExactType&lt;BlocProvider&lt;T&gt;&gt;();
      return _provider.bloc;
    }
  
    State createState() =&gt; _BlocProviderState();
  }
  
  class _BlocProviderState extends State&lt;BlocProvider&gt; {
    @override
    Widget build(BuildContext context) {
      return widget.child;
    }
  
    @override
    void dispose() {
      widget.bloc.dispose();
      super.dispose();
    }
  }
  </code></pre>