useListenable<T extends Listenable?> function
T
useListenable<T extends Listenable?>(
- T listenable
listenable, whose notifications rebuild the element from this build
on: the listener goes over to the listenable of a later build, and is
removed when the element is unmounted. Null listens to nothing.
The offset of a scroll controller made elsewhere, shown as it changes:
HookBuilder(
builder: (context) {
final controller = useListenable(scroll);
return Text('line ${controller.offset + 1}');
},
)
Implementation
T useListenable<T extends Listenable?>(T listenable) =>
use(_ListenableHook<T>(listenable, 'useListenable<$T>'));