I have submit button, but when i press the button it gives this error:

> 
> BlocProvider.of() called with a context that does not contain a
> CreatePostCubit.  
> 
> No ancestor could be found starting from the
> context that was passed to BlocProvider.of(). This
> can happen if the context you used comes from a widget above the
> BlocProvider.
> The context used was: Builder
> 
> 
> 

I suppose contexts get mixed. how can i solve this error?

my code:

```
Widget createPostButton(BuildContext context) {
  final TextEditingController _postTitleController = TextEditingController();

  final TextEditingController _postDetailsController = TextEditingController();
  final TextEditingController _priceController = TextEditingController();

  final _formKey = GlobalKey<FormState>(debugLabel: '_formKey');
  return BlocProvider<CreatePostCubit>(
    create: (context) => CreatePostCubit(),
      child: Padding(
      padding: const EdgeInsets.only(right: 13.0, bottom: 13.0),
      child: FloatingActionButton(
        child: FaIcon(FontAwesomeIcons.plus),
        onPressed: () {
          showDialog(
              context: context,
              barrierDismissible: false,
              builder: (context) {
                return AlertDialog(
                  content: Form(
                    key: _formKey,
                    child: SingleChildScrollView(
                      child: Column(
                        mainAxisSize: MainAxisSize.min,
                        children: <Widget>[
                          Padding(
                              padding: EdgeInsets.all(8.0),
                              child: TextFormField(
                                autocorrect: true,
                                controller: _postTitleController,
                                textCapitalization: TextCapitalization.words,
                                enableSuggestions: false,
                                validator: (value) {
                                  if (value.isEmpty || value.length <= 4) {
                                    return 'Please enter at least 4 characters';
                                  } else {
                                    return null;
                                  }
                                },
                                decoration:
                                    InputDecoration(labelText: 'Post Title'),
                              )),
                          Padding(
                              padding: EdgeInsets.all(8.0),
                              child: TextFormField(
                                controller: _postDetailsController,
                                autocorrect: true,
                                textCapitalization: TextCapitalization.words,
                                enableSuggestions: false,
                                validator: (value) {
                                  if (value.isEmpty || value.length <= 25) {
                                    return 'Please enter at least 25 characters';
                                  } else {
                                    return null;
                                  }
                                },
                                decoration: InputDecoration(
                                    labelText: 'Write a post details'),
                              )),
                          Padding(
                              padding: EdgeInsets.all(8.0),
                              child: TextFormField(
                                controller: _priceController,
                                enableSuggestions: false,
                                inputFormatters: <TextInputFormatter>[
                                  FilteringTextInputFormatter.digitsOnly
                                ],
                                keyboardType: TextInputType.number,
                                validator: (value) {
                                  if (value.isEmpty || value.length >= 4) {
                                    return 'Please enter a valid value';
                                  } else {
                                    return null;
                                  }
                                },
                                decoration:
                                    InputDecoration(labelText: 'Enter the Price'),
                              )),
                          OutlinedButton(
                            style: OutlinedButton.styleFrom(
                              primary: Colors.white,
                              backgroundColor: Colors.blue,
                            ),
                            child: Text("Submit"),
                            onPressed: () => {
                              BlocProvider.of<CreatePostCubit>(context)
                                  .createNewPost(
                                      postTitle: _postTitleController.text,
                                      postDetails: _postDetailsController.text,
                                      price: _priceController.text)
                            },
                          ),
                        ],
                      ),
                    ),
                  ),
                );
              });
        },
      ),
    ),
  );
}

```