useTicker function

Ticker useTicker(
  1. TickerCallback onTick
)

A Ticker made by the first build, not started, that calls the onTick of the latest build once a frame while it is active, in the frames of the app the widget is in; disposed with the element. It is muted (Ticker.muted) while a TickerMode above is off, its time going on.

A clock of the time since its ticker started:

HookBuilder(
  builder: (context) {
    final elapsed = useState(Duration.zero);
    final ticker = useTicker((time) => elapsed.value = time);
    useEffect(() {
      ticker.start();
      return null;
    }, const []);
    return Text('${elapsed.value.inSeconds} s');
  },
)

Implementation

Ticker useTicker(TickerCallback onTick) => use(_TickerHook(onTick));