Bloc: Do I need to create 2 Widgets? (Login example)

Created on 28 Nov 2019  路  6Comments  路  Source: felangel/bloc

Hi, I am following the Login example, and noticed that I need to have the LoginPage and the LoginForm widgets for bloc to work.
Of course I tried to do both on the same Widget (LoginPage), but the BlocListener doesn't work.

Is there a way, or the example is the only right way?

question

Most helpful comment

Sorry, I don't have it on a repository, I will try some more and return with what I find.

All 6 comments

Hi @joaogalli 馃憢
Thanks for opening an issue!

Are you able to share a link to a sample app which illustrates the problem you鈥檙e having? Thanks!

Thanks for your response, I don't have a different code from yours (Login Example), I was just trying to do everything in the same Widget.
In LoginPage there is the creation of LoginForm at line 29, instead of this,
I just tried to return the blocListener of LoginForm at line 25.
But it never get called, like it would if they are in separate widgets.

@joaogalli so you just have one StatefulWidget? It should work the same way. Are you able to share a link to your GitHub repository? I can take a look and create a pull request to fix any issue I find.

Sorry, I don't have it on a repository, I will try some more and return with what I find.

Sounds good. If it鈥檚 easier you can also create a gist and share the link 馃憤

Closing for now but feel free to comment with additional questions or comments and I'm happy to continue the conversation

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ricktotec picture ricktotec  路  3Comments

timtraversy picture timtraversy  路  3Comments

tigranhov picture tigranhov  路  3Comments

rsnider19 picture rsnider19  路  3Comments

MahdiPishguy picture MahdiPishguy  路  3Comments