【Flutter】Flutter異常:xxx was disposed with an active Ticker.

flutter: The following assertion was thrown while finalizing the widget tree:
flutter: _WebViewPageState#e5d3e(ticker active) was disposed with an active Ticker.
flutter: _WebViewPageState created a Ticker via its SingleTickerProviderStateMixin, but at the time dispose()
flutter: was called on the mixin, that Ticker was still active. The Ticker must be disposed before calling
flutter: super.dispose(). Tickers used by AnimationControllers should be disposed by calling dispose() on the
flutter: AnimationController itself. Otherwise, the ticker will leak.

    帶有動畫的頁面關閉後,控制檯報以上異常,經過排查發現_animationController.dispose()的位置不對。_animationController.dispose()的位置應該在super.dispose()前執行。

void dispose() {
    // TODO: implement dispose
    _animationController.dispose();
    super.dispose();
  }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章