Skip to content

[Bug report] Looking up a deactivated widget's ancestor is unsafe. #52

@Rock-chan

Description

@Rock-chan

Version

4.1.2

Platforms

dart, Android, iOS

Device Model

iPhone X iOS16

flutter info

admin@admindeMacBook-Pro app % flutter doctor -v
[!] Flutter (Channel stable, 3.10.5, on macOS 12.6.6 21G646 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.10.5 on channel stable at /Users/admin/development/flutter
    ! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/3.0.4/libexec/bin/dart, which is not inside your current Flutter SDK checkout at
      /Users/admin/development/flutter. Consider adding /Users/admin/development/flutter/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (7 weeks ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/admin/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • ANDROID_HOME = /Users/admin/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.79.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.68.0

[✓] Connected device (3 available)
    • iPhone (4) (mobile) • 00008020-001C589A2203002E • ios            • iOS 16.3.1 20D67
    • macOS (desktop)     • macos                     • darwin-x64     • macOS 12.6.6 21G646 darwin-x64
    • Chrome (web)        • chrome                    • web-javascript • Google Chrome 115.0.5790.114

[!] Network resources             
    ✗ A network error occurred while checking "https://github.com/": Operation timed out

! Doctor found issues in 2 categories.

How to reproduce?

1、When you first go to the page which you use the widget, sometime it will show the error.
2、When you refresh your list, before the data getting, you hold the screen and then you will receive the error.

Logs

I/flutter ( 9284): Caught error: Looking up a deactivated widget's ancestor is unsafe.
I/flutter ( 9284): At this point the state of the widget's element tree is no longer stable.
I/flutter ( 9284): To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.
I/flutter ( 9284): Stack trace:
I/flutter ( 9284): package:flutter/src/widgets/framework.dart 4347:9 Element._debugCheckStateIsActiveForAncestorLookup.<fn>
I/flutter ( 9284): package:flutter/src/widgets/framework.dart 4361:6 Element._debugCheckStateIsActiveForAncestorLookup
I/flutter ( 9284): package:flutter/src/widgets/framework.dart 4396:12 Element.getElementForInheritedWidgetOfExactType
I/flutter ( 9284): package:flutter/src/widgets/inherited_model.dart 143:45 InheritedModel._findModels
I/flutter ( 9284): package:flutter/src/widgets/inherited_model.dart 191:5 InheritedModel.inheritFrom
I/flutter ( 9284): package:flutter/src/widgets/media_query.dart 1058:27 MediaQuery._maybeOf
I/flutter ( 9284): package:flutter/src/widgets/media_query.dart 1101:67 MediaQuery.maybeDevicePixelRatioOf
I/flutter ( 9284): package:flutter/src/widgets/scroll_position.dart 244:45 ScrollPosition.devicePixelRatio
I/flutter ( 9284): package:flutter/src/widgets/

Example code (optional)

No response

Contact

chenzhangjin@outlook.com

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions