dispose method

  1. @protected
  2. @visibleForOverriding
void dispose()

Ref will automatically free associated resources when its associated HookWidget is no longer in use, so the dispose() method of a ValueNotifier or AnimationController is unnecessary.

The DisposeGuard.dispose method throws an error.

Implementation

@protected
@visibleForOverriding
void dispose() {
  assert(
    throw FlutterError.fromParts([
      ErrorSummary('$runtimeType.dispose() was invoked.'),
      ErrorDescription(
        '"Get" objects, including this $runtimeType, persist throughout the app\'s lifecycle, '
        'and calling "dispose" renders them unable to function from that point onward.',
      ),
      ErrorHint('Consider removing the dispose() invocation.'),
    ]),
  );
}