Describe the bug
After Updating the bloc library to 4.0.0 and flutter to 1.17 the VsCode throwing the following errors:
The code causing the error in the bloc:
@override
Stream<PostsState> transformEvents(Stream<PostsEvent> events,
Stream<PostsState> Function(PostsEvent) next) {
return super.transformEvents(
events.debounceTime(const Duration(milliseconds: 300)), next);
}
'PostsBloc.transformEvents' ('Stream<PostsState> Function(Stream<PostsEvent>, Stream<PostsState> Function(PostsEvent))') isn't a valid override of 'Bloc.transformEvents' ('Stream<Transition<PostsEvent, PostsState>> Function(Stream<PostsEvent>, Stream<Transition<PostsEvent, PostsState>> Function(PostsEvent))').
The method 'debounceTime' isn't defined for the type 'Stream'.
Try correcting the name to the name of an existing method, or defining a method named 'debounceTime'.
The argument type 'Stream<PostsState> Function(PostsEvent)' can't be assigned to the parameter type 'Stream<Transition<PostsEvent, PostsState>> Function(PostsEvent)'.
Error one:
{
"resource": "/Volumes/Partion-2/Projects/cars_time_mobile_app/lib/src/blocs/posts/posts_bloc.dart",
"owner": "dart",
"code": {
"value": "invalid_override",
"target": {
"$mid": 1,
"external": "https://dart.dev/tools/diagnostic-messages#invalid_override",
"path": "/tools/diagnostic-messages",
"scheme": "https",
"authority": "dart.dev",
"fragment": "invalid_override"
}
},
"severity": 8,
"message": "'PostsBloc.transformEvents' ('Stream<PostsState> Function(Stream<PostsEvent>, Stream<PostsState> Function(PostsEvent))') isn't a valid override of 'Bloc.transformEvents' ('Stream<Transition<PostsEvent, PostsState>> Function(Stream<PostsEvent>, Stream<Transition<PostsEvent, PostsState>> Function(PostsEvent))').",
"source": "dart",
"startLineNumber": 24,
"startColumn": 22,
"endLineNumber": 24,
"endColumn": 37,
"tags": []
}
Error two:
{
"resource": "/Volumes/Partion-2/Projects/cars_time_mobile_app/lib/src/blocs/posts/posts_bloc.dart",
"owner": "dart",
"code": {
"value": "undefined_method",
"target": {
"$mid": 1,
"external": "https://dart.dev/tools/diagnostic-messages#undefined_method",
"path": "/tools/diagnostic-messages",
"scheme": "https",
"authority": "dart.dev",
"fragment": "undefined_method"
}
},
"severity": 8,
"message": "The method 'debounceTime' isn't defined for the type 'Stream'.\nTry correcting the name to the name of an existing method, or defining a method named 'debounceTime'.",
"source": "dart",
"startLineNumber": 27,
"startColumn": 16,
"endLineNumber": 27,
"endColumn": 28,
"tags": []
}
Last Error:
{
"resource": "/Volumes/Partion-2/Projects/cars_time_mobile_app/lib/src/blocs/posts/posts_bloc.dart",
"owner": "dart",
"code": {
"value": "argument_type_not_assignable",
"target": {
"$mid": 1,
"external": "https://dart.dev/tools/diagnostic-messages#argument_type_not_assignable",
"path": "/tools/diagnostic-messages",
"scheme": "https",
"authority": "dart.dev",
"fragment": "argument_type_not_assignable"
}
},
"severity": 8,
"message": "The argument type 'Stream<PostsState> Function(PostsEvent)' can't be assigned to the parameter type 'Stream<Transition<PostsEvent, PostsState>> Function(PostsEvent)'.",
"source": "dart",
"startLineNumber": 27,
"startColumn": 65,
"endLineNumber": 27,
"endColumn": 69,
"tags": []
}
Hi @heshaShawky 馃憢
Thanks for opening an issue!
The signature updated to:
@override
Stream<Transition<PostsEvent, PostsState>> transformEvents(
Stream<PostsEvent> events,
TransitionFunction<PostsEvent, PostsState> transitionFn) {
return super.transformEvents(
events.debounceTime(const Duration(milliseconds: 300)),
transitionFn,
);
}
Hope that helps 馃憤
Most helpful comment
Hi @heshaShawky 馃憢
Thanks for opening an issue!
The signature updated to:
Hope that helps 馃憤