I am wondering hot to get a stream sorted.
This is my unsorted stream:
Stream<List<User> userStream = userBox.query()
.watch(triggerImmediately: true).map((query)
=> query.find();
Adding ..order()
after query()
or also after map((query) query
adds in pre-compile errors.
Stream<List<User> userStream = userBox.query()
..order(User_.date)
.watch(triggerImmediately: true).map((query)
=> query.find();
Also - what is the difference of the above notation to
Query<User> query = userBox.query().build();
Stream<User stream = query.stream();
await stream.forEach((User user) => print(user));
query.close();
Has a stream()
method be implemented in the meantime?
Using
should work.
stream()
returns the results of the query once,watch()
observes the associated Box and sends a Query whenever there are changes.Source: ObjectBox Dart API reference