select<R> method
Creates a derived query that selects a subset of data.
The derived query shares the lifecycle and state of this query, but only updates its data when the selected value changes.
Important: The returned query listens to the source query. You should dispose it when no longer needed to prevent memory leaks, especially if created inside a build method.
Example:
// In a controller
late final nameQuery = userQuery.select((user) => user.name);
@override
void onClose() {
nameQuery.dispose();
super.onClose();
}
Implementation
ZenQuery<R> select<R>(R Function(T data) selector) {
return _SelectedZenQuery<T, R>(this, selector);
}