Closed caneva20 closed 4 years ago
Hi @caneva20 👋 Thanks for opening an issue!
Sorry for the inconvenience but that is how BlocProvider
works because it can be used within MultiBlocProvider
without a child. I will try to improve the exception to make it more clear 👍
This was fixed in provider and included in v4.0.5 🎉
Hi, I'm new to this library and thus it might not be a bug, but I think it's worth sharing at least :)
Describe the bug If you have a
BlocProvider<SomeBloc>()
without thechild
parameter set you'll get a pretty "obscure" error without any hint to what is wrong about your code. Having aBlocProvider
without a child might not the correct usage of aBlocProvider
, but there's no@required
for thechild
parameter nor anassert(child != null)
To Reproduce Steps to reproduce the behavior:
BlocProvider<SomeBloc>()
with only thecreate
parameter set.Expected behavior an
@required
attribute/annotation so that we can at least have a nice warning in the IDE or anassert(child != null)
telling us what's wrongLogs Run
flutter analyze
and attach any output of that command below. If there are any analysis errors, try resolving them before filing this issue.info - Unused import: 'package:intl/intl.dart' - lib\locales\messages.dart:1:8 - unused_import
info - Unused import: 'package:rxdart/rxdart.dart' - lib\login\bloc\login_bloc.dart:10:8 - unused_import
info - Unused import: 'package:rxdart/rxdart.dart' - lib\register\bloc\register_bloc.dart:10:8 - unused_import
info - Dead code - lib\screens\home_screen.dart:52:5 - dead_code
warning - The parameter 'userRepository' is required. - test\widget_test.dart:16:29 - missing_required_param
Paste the output of running
flutter doctor -v
here. F:\Dev\Flutter\exponential_journey>flutter doctor -v [√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18362.356], locale pt-BR) • Flutter version 1.12.13+hotfix.8 at F:\flutter • Framework revision 0b8abb4724 (4 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\Jesus\AppData\Local\Android\sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • Java binary at: F:\IDEs\apps\AndroidStudio\ch-0\192.6241897\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.
[!] Android Studio (version 3.6) • Android Studio at F:\IDEs\apps\AndroidStudio\ch-0\192.6241897 X Flutter plugin not installed; this adds Flutter specific functionality. X Dart plugin not installed; this adds Dart specific functionality. • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] IntelliJ IDEA Ultimate Edition (version 2019.3) • IntelliJ at F:\IDEs\apps\IDEA-U\ch-0\193.6494.35 • Flutter plugin version 42.1.4 • Dart plugin version 193.5731
[√] VS Code (version 1.43.0) • VS Code at C:\Users\Jesus\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.8.1
[√] Connected device (1 available) • AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
! Doctor found issues in 1 category.
Additional context Add any other context about the problem here.