Skip to content
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

flutter_bloc 6.0.1 (Current Latest) Breaks Constructor "AuthBloc(this._authFacade);" #6

Open
Ezirius opened this issue Aug 1, 2020 · 12 comments

Comments

@Ezirius
Copy link

Ezirius commented Aug 1, 2020

Thanks for the awesome tutorials. Please upgrade the project to the latest BLoC package.

@rdhillbb
Copy link

rdhillbb commented Aug 1, 2020

Question: I get an error message 'The getter 'showErrorMEssages' was called on null. I got this message once I upgraded.
Is this is what you are referring to ?

@Ezirius
Copy link
Author

Ezirius commented Aug 1, 2020

With the following versions in dependencies and dev_dependencies in pubspec.yaml:

dependencies:
dartz: ^0.9.1
freezed_annotation: ^0.11.0
flutter_bloc: ^6.0.1

dev_dependencies:
build_runner: ^1.10.0
freezed: ^0.11.


I get the following on "AuthBloc(this._authFacade);":

The superclass 'Bloc<AuthBlocEvent, AuthBlocState>' doesn't have a zero argument constructor.
Try declaring a zero argument constructor in 'Bloc<AuthBlocEvent, AuthBlocState>', or explicitly invoking a different constructor in 'Bloc<AuthBlocEvent, AuthBlocState>'.dart(no_default_super_constructor)


Remember that you need to add the following override otherwise you will get a "requires the 'non-nullable' language feature to be enabled" error with build_runner:

dependency_overrides:
analyzer: ^0.39.14

I presume that there is a bug in analyzer 0.39.15?

@rdhillbb
Copy link

rdhillbb commented Aug 2, 2020

I am just not getting it on your comment with related to AuthBoc.

@Ezirius
Copy link
Author

Ezirius commented Aug 2, 2020

In bloc.dart...


The Bloc definition in 4.0.0 is:

abstract class Bloc<Event, State> extends Stream<State> implements Sink<Event> {

...

  /// {@macro bloc}
  Bloc() {
    _state = initialState;
    _bindEventsToStates();
  }

...


The Bloc definition in 6.0.1 is:

abstract class Bloc<Event, State> extends Cubit<State>
    implements EventSink<Event> {
  /// {@macro bloc}
  Bloc(State initialState) : super(initialState) {
    _bindEventsToStates();
  }

...


Therefore you get the compile time error, "The superclass 'Bloc<AuthBlocEvent, AuthBlocState>' doesn't have a zero argument constructor."

@rdhillbb
Copy link

rdhillbb commented Aug 2, 2020

I was not clear or I have no clue at all. I am not getting a compile error, i think. It is runtime. If i down grade to
flutter_bloc: ^4.0.0 No issue at all.

return Form(
autovalidate: state.showErrorMessages, <---- Generates Error. state has a null.
════════ Exception caught by widgets library ═══════════════════════════════════
The following NoSuchMethodError was thrown building BlocBuilder<SignInFormBloc, SignInFormState>(dirty, state: _BlocBuilderBaseState<SignInFormBloc, SignInFormState>#2d670):
The getter 'showErrorMessages' was called on null.
Receiver: null
Tried calling: showErrorMessages

The relevant error-causing widget was
BlocConsumer<SignInFormBloc, SignInFormState>
package:notes_firebase_ddd_course/…/widgets/sign_in_form.dart:13
When the exception was thrown, this was the stack
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 SignInForm.build.
package:notes_firebase_ddd_course/…/widgets/sign_in_form.dart:40
#2 BlocBuilder.build

@Ezirius
Copy link
Author

Ezirius commented Aug 2, 2020

Okay, so there are at least 2 separate issues that need to be solved to upgrade the BLoC library to the latest version

@rdhillbb
Copy link

rdhillbb commented Aug 2, 2020

Yes. Does the fix need to be part of Bloc or the application?

@Ezirius
Copy link
Author

Ezirius commented Aug 2, 2020

In the app to accommodate the breaking changes implemented in the BLoC library

@rdhillbb
Copy link

rdhillbb commented Aug 2, 2020

I will stay at 4.0.0 until there is a fix. I am working on an APP that stopped working with the New Bloc.

@Ezirius
Copy link
Author

Ezirius commented Aug 9, 2020

@rdhillbb, not BLoC related, but may help in terms of understanding/implementing Clean Architecture and TDD:

@rdhillbb
Copy link

All I did was take the finished code and upgraded to 6.0.1. No modifications. I will take your suggestions.

@Ezirius
Copy link
Author

Ezirius commented Aug 10, 2020

Glad that worked. Thanks for the update.

@Ezirius Ezirius changed the title flutter_bloc 6.0.1 (current latest) breaks constructor "AuthBloc(this._authFacade);" flutter_bloc 6.0.1 (Current Latest) Breaks Constructor "AuthBloc(this._authFacade);" Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants