marcos930807 / awesomeDialogs

A new Flutter package project for simple a awesome dialogs
Other
339 stars 110 forks source link

Can it return an Awesome dialog as a Widget? #87

Closed Retr0sec7 closed 2 years ago

Retr0sec7 commented 2 years ago

Hello, I'm currently building an app with bloc/cubit state management. I want to show the dialogs based on a current state, but I can't call them outside a button function. So is there any way to return it as a Widget ?

Error: The element type Set<AwesomeDialog> can't be assigned to the list type 'Widget'

So for example:

...
BlocConsumer<SignInCubit, SignInState>(
          builder: (context, state) => Column(children: <Widget>[
          state.status.isSubmissionInProgress ?
                        //...Show Loading Awesome Dialog
          : Container()

])
OutdatedGuy commented 2 years ago

The dialog is shown using the function showDialog. Hence it is not a widget and cannot be used as a widget.

marcos930807 commented 2 years ago

@Retr0sec7 a little late maybe but, you could use BlocListener to react to state changes on your cubit or bloc, then show the dialog. Hope that helps.