-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BlocBuilder provides initial state instead of actual state. #29
Comments
@algirdasmac thanks for reporting this! I'll have a fix shortly 👍 |
Fixed in #30 and published in flutter_bloc v0.4.6 |
Thanks! Really helped me out! 👍 |
I was just about to create an issue for this, then I saw that the version got bumped from |
@felangel, could you help me? I'm having this same issue, but only when I use a BlocBuilder inside of a stateful widget. Putting some context: I'm building an app to learn how to use BLoC, and one of the use cases is a Tic Tac Toe game. See this file. At line 81 I dispatch an event. (tictactoe.dart) Here is the BLoC: tictactoe_bloc.dart Sorry if this is the wrong place for it, but I didnt want to open a new issue just for that. |
Hi @arthurcohen 👋 Hope that helps 👍 |
So, my mistake was not using the Equatable the right way, passing the currentPlayer in the props, for the builder at BlocBuilder be called again? Your solution works perfectly here! 👍 Thank you! |
Describe the bug
It seems that BlocBuilder is not showing actual state, but an initial one. State in the app is managed correctly, and Bloc is provided to the Widget.
To Reproduce
You can reproduce the error by trying to use BlocBuilder in widget, where you provide Bloc with BlocProvider.of(context); It seems that problem is happening only in this case. Does the same on login flow example, if you try using BlocBuilder in home_page.dart
Expected behavior
I expect to get actual state instead of initial one.
Code
main.dart BlocBuilder works with authBloc, profile_page.dart BlocBuilder does not work, but StreamBuilder works. This leads me to believe, that Bloc is provided correctly. onPressed events also work.
main.dart
profile_page.dart
**Logs **
flutter analyze:
No issues found! (ran in 3.2s)
flutter doctor -v:
[✓] Flutter (Channel beta, v1.0.0, on Mac OS X 10.14.1 18B75, locale en-LT)
• Flutter version 1.0.0 at /Users/algirdas/development/flutter
• Framework revision 5391447fae (11 days ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /Users/algirdas/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /Users/algirdas/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.1, Build version 10B61
• ios-deploy 1.9.4
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 31.1.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.29.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.21.1
[✓] Connected device (1 available)
• iPhone XS Max • 3A626DC0-8339-4895-B831-738F98A987DA • ios • iOS 12.1 (simulator)
• No issues found!
The text was updated successfully, but these errors were encountered: