Search code examples
flutterdartstreamobservablerxdart

flutter error: The method 'combineLatest4' isn't defined for the type 'Observable'


My project never update for 6 months (written by someone & last build was successful), but today I want to update it but face some errors:

lib/src/blocs/account/account_bloc.dart:69:33: Error: The getter 'Observable' isn't defined for the class 'AccountBloc'.

Try correcting the name to the name of an existing getter, or defining a getter or field named 'Observable'.

it seems Observable come from rxdart library, but I'm not sure about it.

My Code:

//Merging username and password streams
Stream<bool> get saveValid => Observable.combineLatest4(nameStream, phoneNumberStream, emailStream, addressStream, (name, phoneNumber, email, address) => true);

rxdart version in my pubspec.yaml : rxdart: ">=0.18.1 <0.24.1"

any idea to solve this?


Solution

  • RxDart v0.23 replaced the Observable class with extension methods. You now need to use the static Rx.combineLatest4() instead. If you look at the change log for RxDart on pub.dev you'll see you can run a package rxdart_codemod to migrate your RxDart code.

    https://pub.dev/documentation/rxdart/latest/rx/Rx/combineLatest4.html