dispose method Null safety

  1. @override
void dispose()
override

Release the resources used by this object. The object is no longer usable after this method is called.

The most recently returned TickerFuture, if any, is marked as having been canceled, meaning the future never completes and its TickerFuture.orCancel derivative future completes with a TickerCanceled error.

Implementation

@override
void dispose() {
  assert(() {
    if (_ticker == null) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary('AnimationController.dispose() called more than once.'),
        ErrorDescription('A given $runtimeType cannot be disposed more than once.\n'),
        DiagnosticsProperty<AnimationController>(
          'The following $runtimeType object was disposed multiple times',
          this,
          style: DiagnosticsTreeStyle.errorProperty,
        ),
      ]);
    }
    return true;
  }());
  _ticker!.dispose();
  _ticker = null;
  clearStatusListeners();
  clearListeners();
  super.dispose();
}