title: How can pass parameter to flutter BLoc?
body: <p>I'm trying to pass parameters to a bloc event following the bloc pattern for set the default counter. I have found this question before, but that is doesn't work.</p>
  <p><a href="https://stackoverflow.com/questions/62124731/flutter-bloc-pass-parameters">Flutter BLoc pass parameters</a></p>
  <p><a href="https://stackoverflow.com/questions/56885956/flutter-bloc-how-to-pass-parameter-to-event">Flutter BLoC - How to pass parameter to event?</a></p>
  <p>main.dart</p>
  <pre><code>BlocProvider(
    create: (_) =&gt; CounterBloc(),
    child: Counter(total: totalItem)
  )
  </code></pre>
  <p>counter_bloc.dart</p>
  <pre><code>import 'package:bloc/bloc.dart';
  import 'package:flutter/material.dart';
  
  
  enum CounterStatus { decrement, increment }
  
  
  class CounterEvent {
    final int value;
    final CounterStatus status;
  
    CounterEvent({@required this.value, @required this.status});
  }
  
  class CounterBloc extends Bloc&lt;CounterEvent, int&gt; {
    CounterBloc() : super(1);
    
    @override
    Stream&lt;int&gt; mapEventToState(event) async* {
      if(event.status == CounterStatus.decrement) {
        yield state + event.value - 1;
      } else if(event.status == CounterStatus.increment) {
        yield state + event.value + 1;
      }
    }
  }
  </code></pre>
  <p>i want to pass parameter to BLoc event like</p>
  <pre><code>FlatButton(
    onPressed: () =&gt; context.bloc&lt;CounterBloc&gt;().add(CounterEvent(value = widget.total, status = CounterStatus.decrement)),
    color: Colors.white,
    child: Text(&quot;-&quot;, style: TextStyle(fontSize: 16), textAlign: TextAlign.center,)
  ),
  FlatButton(
    onPressed: () =&gt; context.bloc&lt;CounterBloc&gt;().add(CounterEvent(value = widget.total, status = CounterStatus.increment)),
    color: Colors.white,
    child: Text(&quot;+&quot;, style: TextStyle(fontSize: 16), textAlign: TextAlign.center,)
  ),
  </code></pre>
  <p>it's still doesn't work</p>