flutterdata / flutter_data

Seamlessly manage persistent data in your Flutter apps
MIT License
410 stars 31 forks source link

Question: is it possible to get stream of model events? #209

Closed andreystavitsky closed 1 year ago

andreystavitsky commented 1 year ago

I'm usig flutter_bloc and I want to listen to user's changes. How can I do that?

final repository = GetIt.instance.get<Repository<AppUser>>();

repository.watchOne(user.id) => _CastError (Null check operator used on a null value)
repository.watchOneNotifier(user.id) => _CastError (Null check operator used on a null value)
frank06 commented 1 year ago

At some point I assumed clients all use Riverpod and stopped testing with other libraries like Provider, GetIt or bloc.

You could try repository.remoteAdapter.watchOneNotifier(...) but note that you will have to pass the model's key that you can obtain via DataModel.keyFor(model).