createTicker method

  1. @override
Ticker createTicker (TickerCallback onTick)

Creates a ticker with the given callback.

The kind of ticker provided depends on the kind of ticker provider.


Ticker createTicker(TickerCallback onTick) {
  assert(() {
    if (_ticker == null)
      return true;
    throw FlutterError(
      '$runtimeType is a SingleTickerProviderStateMixin but multiple tickers were created.\n'
      'A SingleTickerProviderStateMixin can only be used as a TickerProvider once. If a '
      'State is used for multiple AnimationController objects, or if it is passed to other '
      'objects and those objects might use it more than one time in total, then instead of '
      'mixing in a SingleTickerProviderStateMixin, use a regular TickerProviderStateMixin.'
  _ticker = Ticker(onTick, debugLabel: 'created by $this');
  // We assume that this is called from initState, build, or some sort of
  // event handler, and that thus TickerMode.of(context) would return true. We
  // can't actually check that here because if we're in initState then we're
  // not allowed to do inheritance checks yet.
  return _ticker;