listenable library
select and listen as methods, for an app that wants them.
Both are extensions on the framework's own types — ValueListenable and
Listenable — and that is why they live here, together with the
SoloSubscription and SoloSubscriptions that listen hands back, rather
than in flutter_solo.dart: two extensions with the same member name on one
type are ambiguous at every call site, so a package that puts a listen of
its own on Listenable would stop compiling beside this one. The import is
the choice — take it alongside flutter_solo.dart where the methods are
wanted.
import 'package:flutter_solo/flutter_solo.dart';
import 'package:flutter_solo/listenable.dart';
final canSave = controller.select((state) => state.canSave);
final subscription = canSave.listen(() => print(canSave.value));
Neither method is the only way in: without this import
SoloSelection(controller, (state) => state.canSave) builds the same
selection, and SoloSelector picks without holding one at all.
Classes
- SoloSubscription
- A listener registered on a Listenable, and the way to take it back.
- SoloSubscriptions
- A group of subscriptions cancelled together, for a screen or an object that listens to several things at once.
Extensions
- SoloListen on Listenable
- listen on every Listenable.
-
SoloSelect
on ValueListenable<
S> - select on every ValueListenable.