title: Extracting bottom modal sheet into separate widget looses BlocProvider flutter
body: <p>First of all I hope your all well in this globally very hard hitting period. I'm refactoring parts of my screens codes and I'm stuck with this.
  I have a bottom modal sheet I extracted into a separate file to keep my <code>MapScreen</code> UI code short and clear but something goes wrong. The error I get is <code>BlocProvider.of() called with a context that does not contain a Bloc of type TrackingBloc.</code> Does that men that I have to declare a BlocProvider also in the separate file? Doesn't it get passed to the widget with the <code>context:context</code> parameter? I then tried adding it but still get the error. Can you spot what I'm doing wrong?
  As always thank you very much for your time and help, especially in this very hard time. </p>
  
  <p>UI modal bottom sheet:</p>
  
  <pre><code>showModalBottomSheet(
                                isScrollControlled: true,
                                context: context,
                                builder: (modal) {
  //                                return AndroidTrackingSheet(routeName,
  //                               isTracking, _textEditingController);
                                  return Container(
                                    color: Color(0xff757575),
                                    child: SingleChildScrollView(
                                      child: Container(
                                        padding: EdgeInsets.only(
                                            left: 20,
                                            right: 20,
                                            bottom: MediaQuery.of(modal)
                                                .viewInsets
                                                .bottom),
                                        decoration: BoxDecoration(
                                          color: Colors.white,
                                          borderRadius: BorderRadius.all(
                                              Radius.circular(20)),
                                        ),
                                        child: Center(
                                          child: Column(
  //                                        mainAxisAlignment:
  //                                            MainAxisAlignment.center,
                                            crossAxisAlignment:
                                                CrossAxisAlignment.stretch,
                                            children: &lt;Widget&gt;[
                                              SizedBox(
                                                height: 10,
                                              ),
                                              Text(
                                                'Nuovo percorso',
                                                textAlign: TextAlign.center,
                                                style: TextStyle(
                                                  fontSize: 25,
                                                  color: Colors.orangeAccent,
                                                  fontWeight: FontWeight.w400,
                                                ),
                                              ),
                                              SizedBox(
                                                height: 10,
                                              ),
                                              Text(
                                                'Inserisci un nome per il tuo nuovo percorso, e scegli Inizia tracking. Quando sarai arrivato a destinazione premi di nuovo il bottone Tracking e scegli Fine tracking.',
                                                textAlign: TextAlign.center,
                                                style: TextStyle(
                                                    fontSize: 18,
                                                    color: Colors.black,
                                                    fontWeight: FontWeight.w400),
                                              ),
                                              SizedBox(
                                                height: 10,
                                              ),
                                              TextField(
                                                controller:
                                                    _textEditingController,
                                                autofocus: true,
                                                textAlign: TextAlign.center,
                                                showCursor: true,
                                                decoration: InputDecoration(
                                                  hintText: isTracking
                                                      ? routeName
                                                      : 'nome percorso',
                                                  labelStyle: TextStyle(
                                                      fontSize: 18,
                                                      color: Colors.black,
                                                      fontWeight:
                                                          FontWeight.w100),
                                                  border: OutlineInputBorder(),
  //                                              focusColor:
  //                                                  Colors.lightGreenAccent,
                                                  focusedBorder:
                                                      OutlineInputBorder(
                                                    borderSide: BorderSide(
                                                      color: Colors.orange,
                                                      width: 1,
                                                    ),
                                                  ),
                                                ),
                                              ),
                                              SizedBox(
                                                height: 10,
                                              ),
                                              FlatButton(
                                                color: Colors.orangeAccent,
                                                child: Text(
                                                  isTracking
                                                      ? "Fine tracking"
                                                      : 'Inizia tracking',
                                                  style: TextStyle(
                                                      fontSize: 18,
                                                      color: Colors.white),
                                                ),
                                                onPressed: () {
                                                  print(
                                                      "Action 2 is been clicked");
                                                  routeName =
                                                      _textEditingController.text;
                                                  Navigator.pop(context);
                                                  isTracking = !isTracking;
                                                  BlocProvider.of&lt;TrackingBloc&gt;(
                                                          context)
                                                      .add(StartStopTracking());
                                                },
                                              ),
                                              SizedBox(
                                                height: 10,
                                              ),
                                              FlatButton(
                                                color: Colors.redAccent,
                                                child: Text(
                                                  'Cancella',
                                                  style: TextStyle(
                                                      fontSize: 18,
                                                      color: Colors.white),
                                                ),
                                                onPressed: () {
                                                  Navigator.pop(context);
                                                },
                                              ),
                                              SizedBox(
                                                height: 10,
                                              ),
                                            ],
                                          ),
                                        ),
                                      ),
                                    ),
                                  );
                                });
  </code></pre>
  
  <p>Separate widget modal sheet:</p>
  
  <pre><code>    class AndroidTrackingSheet extends StatelessWidget {
    TextEditingController _textEditingController;
    bool isTracking;
    String routeName;
    AndroidTrackingSheet(
        this.routeName, this.isTracking, this._textEditingController);
    @override
    Widget build(BuildContext context) {
      return Container(
        color: Color(0xff757575),
        child: SingleChildScrollView(
          child: Container(
            padding: EdgeInsets.only(
                left: 20,
                right: 20,
                bottom: MediaQuery.of(context).viewInsets.bottom),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(20)),
            ),
            child: Center(
              child: Column(
  //                                        mainAxisAlignment:
  //                                            MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: &lt;Widget&gt;[
                  SizedBox(
                    height: 10,
                  ),
                  Text(
                    'Nuovo percorso',
                    textAlign: TextAlign.center,
                    style: TextStyle(
                      fontSize: 25,
                      color: Colors.orangeAccent,
                      fontWeight: FontWeight.w400,
                    ),
                  ),
                  SizedBox(
                    height: 10,
                  ),
                  Text(
                    'Inserisci un nome per il tuo nuovo percorso, e scegli Inizia tracking. Quando sarai arrivato a destinazione premi di nuovo il bottone Tracking e scegli Fine tracking.',
                    textAlign: TextAlign.center,
                    style: TextStyle(
                        fontSize: 18,
                        color: Colors.black,
                        fontWeight: FontWeight.w400),
                  ),
                  SizedBox(
                    height: 10,
                  ),
                  TextField(
                    controller: _textEditingController,
                    autofocus: true,
                    textAlign: TextAlign.center,
                    showCursor: true,
                    decoration: InputDecoration(
                      hintText: isTracking ? routeName : 'nome percorso',
                      labelStyle: TextStyle(
                          fontSize: 18,
                          color: Colors.black,
                          fontWeight: FontWeight.w100),
                      border: OutlineInputBorder(),
  //                                              focusColor:
  //                                                  Colors.lightGreenAccent,
                      focusedBorder: OutlineInputBorder(
                        borderSide: BorderSide(
                          color: Colors.orange,
                          width: 1,
                        ),
                      ),
                    ),
                  ),
                  SizedBox(
                    height: 10,
                  ),
                  FlatButton(
                    color: Colors.orangeAccent,
                    child: Text(
                      isTracking ? "Fine tracking" : 'Inizia tracking',
                      style: TextStyle(fontSize: 18, color: Colors.white),
                    ),
                    onPressed: () {
                      print("Action 2 is been clicked");
                      routeName = _textEditingController.text;
                      Navigator.pop(context);
                      isTracking = !isTracking;
                      BlocProvider.of&lt;TrackingBloc&gt;(context)
                          .add(StartStopTracking());
                    },
                  ),
                  SizedBox(
                    height: 10,
                  ),
                  FlatButton(
                    color: Colors.orangeAccent,
                    child: Text(
                      'Cancella',
                      style: TextStyle(fontSize: 18, color: Colors.white),
                    ),
                    onPressed: () {
                      Navigator.pop(context);
                    },
                  ),
                  SizedBox(
                    height: 10,
                  ),
                ],
              ),
            ),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>Separate bottom sheet with bloc provider:</p>
  
  <pre><code>class AndroidTrackingBottomSheet extends StatelessWidget {
    TextEditingController _textEditingController;
    bool isTracking;
    String routeName;
    AndroidTrackingBottomSheet(
        this.routeName, this.isTracking, this._textEditingController);
    @override
    Widget build(BuildContext context) {
      return BlocProvider&lt;TrackingBloc&gt;(
        create: (context) =&gt; TrackingBloc(),
        child: Container(
          color: Color(0xff757575),
          child: SingleChildScrollView(
            child: Container(
              padding: EdgeInsets.only(
                  left: 20,
                  right: 20,
                  bottom: MediaQuery.of(context).viewInsets.bottom),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.all(Radius.circular(20)),
              ),
              child: Center(
                child: Column(
  //                                        mainAxisAlignment:
  //                                            MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: &lt;Widget&gt;[
                    SizedBox(
                      height: 10,
                    ),
                    Text(
                      'Nuovo percorso',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                        fontSize: 25,
                        color: Colors.orangeAccent,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    Text(
                      'Inserisci un nome per il tuo nuovo percorso, e scegli Inizia tracking. Quando sarai arrivato a destinazione premi di nuovo il bottone Tracking e scegli Fine tracking.',
                      textAlign: TextAlign.center,
                      style: TextStyle(
                          fontSize: 18,
                          color: Colors.black,
                          fontWeight: FontWeight.w400),
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    TextField(
                      controller: _textEditingController,
                      autofocus: true,
                      textAlign: TextAlign.center,
                      showCursor: true,
                      decoration: InputDecoration(
                        hintText: isTracking ? routeName : 'nome percorso',
                        labelStyle: TextStyle(
                            fontSize: 18,
                            color: Colors.black,
                            fontWeight: FontWeight.w100),
                        border: OutlineInputBorder(),
  //                                              focusColor:
  //                                                  Colors.lightGreenAccent,
                        focusedBorder: OutlineInputBorder(
                          borderSide: BorderSide(
                            color: Colors.orange,
                            width: 1,
                          ),
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    FlatButton(
                      color: Colors.orangeAccent,
                      child: Text(
                        isTracking ? "Fine tracking" : 'Inizia tracking',
                        style: TextStyle(fontSize: 18, color: Colors.white),
                      ),
                      onPressed: () {
                        print("Action 2 is been clicked");
                        routeName = _textEditingController.text;
                        Navigator.pop(context);
                        isTracking = !isTracking;
                        BlocProvider.of&lt;TrackingBloc&gt;(context)
                            .add(StartStopTracking());
                      },
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    FlatButton(
                      color: Colors.orangeAccent,
                      child: Text(
                        'Cancella',
                        style: TextStyle(fontSize: 18, color: Colors.white),
                      ),
                      onPressed: () {
                        Navigator.pop(context);
                      },
                    ),
                    SizedBox(
                      height: 10,
                    ),
                  ],
                ),
              ),
            ),
          ),
        ),
      );
    }
  }
  </code></pre>