-
Notifications
You must be signed in to change notification settings - Fork 201
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
Error: Type 'FormBloc' can't use itself as a bound. #339
Comments
I am having the same issue, is there any solution yet? |
I'm also having the same issue |
Anyone who managed to have it solved on local branch please?? |
Change the complete code of this file: import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:form_bloc/form_bloc.dart' as form_bloc;
typedef FormBlocListenerCallback<
FormBlocState2 extends form_bloc
.FormBlocState<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>
= void Function(BuildContext context, FormBlocState2 state);
/// [BlocListener] that reacts to the state changes of the FormBloc.
class FormBlocListener<
FormBloc2 extends form_bloc.FormBloc<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>
extends BlocListener<FormBloc2,
form_bloc.FormBlocState<SuccessResponse, ErrorResponse>> {
/// [BlocListener] that reacts to the state changes of the FormBloc.
/// {@macro bloclistener}
FormBlocListener({
Key? key,
this.formBloc,
Widget? child,
this.onLoading,
this.onLoaded,
this.onLoadFailed,
this.onSubmitting,
this.onSuccess,
this.onFailure,
this.onSubmissionCancelled,
this.onSubmissionFailed,
this.onDeleting,
this.onDeleteFailed,
this.onDeleteSuccessful,
}) : super(
key: key,
child: child,
bloc: formBloc,
listenWhen: (previousState, state) =>
previousState.runtimeType != state.runtimeType,
listener: (context, state) {
if (state is form_bloc.FormBlocLoading<SuccessResponse, ErrorResponse> &&
onLoading != null) {
onLoading(context, state);
} else if (state is form_bloc.FormBlocLoaded<SuccessResponse, ErrorResponse> &&
onLoaded != null) {
onLoaded(context, state);
} else if (state is form_bloc.FormBlocLoadFailed<SuccessResponse, ErrorResponse> &&
onLoadFailed != null) {
onLoadFailed(context, state);
} else if (state is form_bloc
.FormBlocSubmitting<SuccessResponse, ErrorResponse> &&
onSubmitting != null) {
onSubmitting(context, state);
} else if (state is form_bloc.FormBlocSuccess<SuccessResponse, ErrorResponse> &&
onSuccess != null) {
onSuccess(context, state);
} else if (state is form_bloc.FormBlocFailure<SuccessResponse, ErrorResponse> &&
onFailure != null) {
onFailure(context, state);
} else if (state is form_bloc.FormBlocSubmissionCancelled<SuccessResponse, ErrorResponse> &&
onSubmissionCancelled != null) {
onSubmissionCancelled(context, state);
} else if (state is form_bloc
.FormBlocSubmissionFailed<SuccessResponse, ErrorResponse> &&
onSubmissionFailed != null) {
onSubmissionFailed(context, state);
} else if (state is form_bloc.FormBlocDeleting<SuccessResponse, ErrorResponse> &&
onDeleting != null) {
onDeleting(context, state);
} else if (state is form_bloc
.FormBlocDeleteFailed<SuccessResponse, ErrorResponse> &&
onDeleteFailed != null) {
onDeleteFailed(context, state);
} else if (state is form_bloc
.FormBlocDeleteSuccessful<SuccessResponse, ErrorResponse> &&
onDeleteSuccessful != null) {
onDeleteSuccessful(context, state);
}
},
);
/// {@macro form_bloc.form_state.FormBlocLoading}
final FormBlocListenerCallback<
form_bloc.FormBlocLoading<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onLoading;
/// {@macro form_bloc.form_state.FormBlocLoaded}
final FormBlocListenerCallback<
form_bloc.FormBlocLoaded<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onLoaded;
/// {@macro form_bloc.form_state.FormBlocLoadFailed}
final FormBlocListenerCallback<
form_bloc.FormBlocLoadFailed<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onLoadFailed;
/// {@macro form_bloc.form_state.FormBlocSubmitting}
final FormBlocListenerCallback<
form_bloc.FormBlocSubmitting<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onSubmitting;
/// {@macro form_bloc.form_state.FormBlocSuccess}
final FormBlocListenerCallback<
form_bloc.FormBlocSuccess<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onSuccess;
/// {@macro form_bloc.form_state.FormBlocFailure}
final FormBlocListenerCallback<
form_bloc.FormBlocFailure<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onFailure;
/// {@macro form_bloc.form_state.FormBlocSubmissionCancelled}
final FormBlocListenerCallback<
form_bloc.FormBlocSubmissionCancelled<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onSubmissionCancelled;
/// {@macro form_bloc.form_state.FormBlocSubmissionFailed}
final FormBlocListenerCallback<
form_bloc.FormBlocSubmissionFailed<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onSubmissionFailed;
/// {@macro form_bloc.form_state.FormBlocSubmissionFailed}
final FormBlocListenerCallback<
form_bloc.FormBlocDeleting<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onDeleting;
/// {@macro form_bloc.form_state.FormBlocSubmissionFailed}
final FormBlocListenerCallback<
form_bloc.FormBlocDeleteFailed<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onDeleteFailed;
/// {@macro form_bloc.form_state.FormBlocSubmissionFailed}
final FormBlocListenerCallback<
form_bloc.FormBlocDeleteSuccessful<SuccessResponse, ErrorResponse>,
SuccessResponse,
ErrorResponse>? onDeleteSuccessful;
/// If the [formBloc] parameter is omitted, [FormBlocListener]
/// will automatically perform a lookup using
/// [BlocProvider].of<[FormBloc]> and the current [BuildContext].
final FormBloc2? formBloc;
/// The [Widget] which will be rendered as a descendant of the [BlocListener].
@override
Widget? get child => super.child;
} |
for me its a compiler bug flutter/flutter#138785 not a formbloc bug. |
I am also facing the same issue. Any solution other than flutter downgrade? |
For a quick fix, you can use the forked version of @Cavin6080 as below:
I hope it will help you. |
If someone interested to fix it, open a issue @dart/language repos. |
Same problemReproduction steps:Created a new project Flutter doctor ResultsDoctor summary (to see all details, run flutter doctor -v): Error Log
|
Thank you for the quick fix @Cavin6080 Any idea on who owns this, in terms of fixing? Should this be with flutter_form_bloc or with the flutter team? |
Hi @94Sip, I think this issue is with the new update of Dart as far as I can tell. But the fix is quite easy, thus it would make sense as of now to just make the changes according to it so that people don't run into those issues. |
@94Sip the Bug is accepted by the dart/sdk team here: dart-lang/sdk#54164. |
Also slowly migrating to reactive_forms as it seems this project is dead. |
Hey @AncientPixel
|
Hey Guys!
Looks like the last flutter upgrade is breaking this package.
The text was updated successfully, but these errors were encountered: