Bloc: Flutter 1.17 and bloc 4.00 update: Transform isn't a valid override

Created on 10 May 2020  路  4Comments  路  Source: felangel/bloc

Being a complete novice I can't seem to figure this out. I had:

Stream<ActivityEvent> transform(Stream<ActivityEvent> events) { return (events as Observable<ActivityEvent>) .debounce(Duration(milliseconds: 500)); }

In earlier version which worked perfect, however now I'm getting both:

  • Transform not being valid override
  • Observable isn't a type so it can't be used in an 'as' expression

Any help would be much appreciated, at total loss why this happens (have tried to read the change logs but not skilled enough to get it)

question

Most helpful comment

Many many thanks! You saved my night :).

All 4 comments

Hi @Luppakorva 馃憢
Thanks for opening an issue!

There are two transforms in v4.0.0 (transformEvents and transformTransitions).

In your case, you can replace your code with:

  @override
  Stream<Transition<ActivityEvent, ActivityState>> transformEvents(
    Stream<ActivityEvent> events,
    TransitionFunction<ActivityEvent, ActivityState> transitionFn,
  ) {
    return super.transformEvents(
      events.debounceTime(const Duration(milliseconds: 500)),
      transitionFn,
    );
  }

Hope that helps 馃憤

Thank you so much for the quick reply and sorry to bother with a follow up,

events.debounceTime is not playing ball, instead getting:

error: The method 'debounceTime' isn't defined for the type 'Stream'.

Any chance you could hint me to right direction why this happens?

You need to make sure you add rxdart as a dependency and import it.

Many many thanks! You saved my night :).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

craiglabenz picture craiglabenz  路  3Comments

abinvp picture abinvp  路  3Comments

shawnchan2014 picture shawnchan2014  路  3Comments

krusek picture krusek  路  3Comments

Reidond picture Reidond  路  3Comments