Ticker constructor

Ticker(
  1. TickerCallback _onTick, {
  2. String? debugLabel,
})

Creates a ticker that will call the provided callback once per frame while running.

An optional label can be provided for debugging purposes. That label will appear in the toString output in debug builds.

Implementation

Ticker(this._onTick, { this.debugLabel }) {
  assert(() {
    _debugCreationStack = StackTrace.current;
    return true;
  }());
  // TODO(polina-c): stop duplicating code across disposables
  // https://github.com/flutter/flutter/issues/137435
  if (kFlutterMemoryAllocationsEnabled) {
    FlutterMemoryAllocations.instance.dispatchObjectCreated(
      library: 'package:flutter/scheduler.dart',
      className: '$Ticker',
      object: this,
    );
  }
}