dispose method

  1. @override
void dispose()
override

清理资源 在 StatefulWidget 被从树中移除并销毁时调用的,这个方法用于清理资源。

Called when the widget is removed from the tree permanently. Used to release resources.

Implementation

@override
void dispose() {
  logi("[lifecycle] dispose");

  // 销毁 ValueNotifier
  _disposeValueNotifiers();

  // 销毁共享动画管理器
  _animationManager.dispose();

  // 移除观察者
  WidgetsBinding.instance.removeObserver(this);

  super.dispose();
}