title: A value of type 'Null' can't be assigned to a parameter of type 'Widget Function(BuildContext, CounterState)' in a const constructor
body: <p>This is an project where I'm trying to implement (and understand) Bloc methodology.</p>
  <p>I got the error:</p>
  <pre><code>A value of type 'Null' can't be assigned to a parameter of type 'Widget Function(BuildContext, CounterState)' in a const constructor.
  </code></pre>
  <p>on the following code (this is the main.dart):</p>
  <pre><code>import 'package:example20221002/cubit/counter_cubit.dart';
  import 'package:example20221002/cubit/counter_state.dart';
  import 'package:flutter/material.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';
  
  void main() {
    runApp(const MyApp());
  }
  
  class MyApp extends StatelessWidget {
    const MyApp({Key? key}) : super(key: key);
    // This widget is the root of your application.
    @override
    Widget build(BuildContext context) {
      return BlocProvider(
        create: (context) =&gt; CounterCubit(),
        child: MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        ),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    const MyHomePage({Key? key, required this.title}) : super(key: key);
    final String title;
    @override
    State&lt;MyHomePage&gt; createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    int _counter = 0;
    void _incrementCounter() {
      setState(() {
        _counter++;
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: &lt;Widget&gt;[
              const BlocBuilder&lt;CounterCubit, CounterState&gt;(
                builder: (context, state) {  // --&lt; ERROR start here
                   return Text(
                    'Counter Value:'+ state.counterValue.toString(),
                  );
                },
              ),
             
              Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
                FloatingActionButton(
                  onPressed: () {
                    BlocProvider.of&lt;CounterCubit&gt;(context).dec();
                  },
                  tooltip: 'Decrement',
                  child: const Icon(Icons.add),
                ),
                FloatingActionButton(
                  onPressed: () {
                    BlocProvider.of&lt;CounterCubit&gt;(context).inc();
                  },
                  tooltip: 'Inc',
                  child: const Icon(Icons.add_alarm),
                ),
              ])
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _incrementCounter,
          tooltip: 'Increment',
          child: const Icon(Icons.add),
        ), // This trailing comma makes auto-formatting nicer for build methods.
      );
    }
  }
  
             
  </code></pre>
  <p>the countercubit .dart is:</p>
  <pre><code>import 'package:bloc/bloc.dart';
  import 'package:bloc/bloc.dart';
  import 'counter_state.dart';
  
   class CounterCubit extends Cubit&lt;CounterState&gt;{
    CounterCubit() : super(CounterState(counterValue: 0));
  
    void inc() =&gt; emit (CounterState(counterValue: state.counterValue+1));
    void dec() =&gt; emit (CounterState(counterValue: state.counterValue-1));
   }
  //import 'package:meta/meta.dart';
  import 'counter_state.dart';
  //part 'counter_state.dart';
   class CounterCubit extends Cubit&lt;CounterState&gt;{
    CounterCubit() : super(CounterState(counterValue: 0));
    void inc() =&gt; emit (CounterState(counterValue: state.counterValue+1));
    void dec() =&gt; emit (CounterState(counterValue: state.counterValue-1));
   }
  </code></pre>
  <p>and the counterstate.dart:</p>
  <pre><code>import 'package:bloc/bloc.dart';
  import 'package:meta/meta.dart';
  //import 'counter_cubit.dart';
  
  //part of 'counter_cubit.dart';
  
  
  class CounterState {
      int counterValue=0;
      
      CounterState ({
     required this.counterValue,
     });
  
  }
  </code></pre>
  <p>As much as I tried, I don't understand the error:</p>
  <ol>
  <li>Why Null?</li>
  <li>On which parameter?</li>
  <li>How can I fix it?</li>
  <li>is the null is about BuildContext? CounterState?</li>
  </ol>
  <p>Many thanks</p>