-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
a: mouseIssues related to using a mouse or mouse supportIssues related to using a mouse or mouse supportc: crashStack traces logged to the consoleStack traces logged to the consolef: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 2.8Found to occur in 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9Found to occur in 2.9frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Issue Description
When I use the Tooltip widget in my StatefulWidget, it will have the problem of "the state no longer has a context" or "AnimationController methods should not be used after calling dispose.".
I can control the state of my StatefulWidget, but I cannot control the state of Tooltip.
Steps to Reproduce
- Use the
Tooltipwidget in your StatefulWidget. - The
Tooltipwidget can be displayed or hidden according to state variables. - Control whether the
Tooltipwidget is displayed by moving in or out of the mouse. - Move the mouse quickly on this
Tooltipwidget.
Phenomena and Error Log
iShot2022-01-20.09.54.26.mp4
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 487 pos 7: '_ticker != null': AnimationController.reverse() called after AnimationController.dispose()
AnimationController methods should not be used after calling dispose.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:47:61)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2 AnimationController.reverse (package:flutter/src/animation/animation_controller.dart:487:7)
#3 _rootRun (dart:async/zone.dart:1420:47)
#4 _CustomZone.run (dart:async/zone.dart:1328:19)
#5 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
#6 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
#7 _rootRun (dart:async/zone.dart:1428:13)
#8 _CustomZone.run (dart:async/zone.dart:1328:19)
#9 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1260:23)
#10 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#11 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
#12 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
#13 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
or
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: This widget has been unmounted, so the State no longer has a context (and should be considered defunct).
Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.
#0 State.context.<anonymous closure> (package:flutter/src/widgets/framework.dart:909:9)
#1 State.context (package:flutter/src/widgets/framework.dart:915:6)
#2 _TooltipState._createNewEntry (package:flutter/src/material/tooltip.dart:535:7)
#3 _TooltipState.ensureTooltipVisible (package:flutter/src/material/tooltip.dart:517:5)
#4 _rootRun (dart:async/zone.dart:1420:47)
#5 _CustomZone.run (dart:async/zone.dart:1328:19)
#6 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
#7 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
#8 _rootRun (dart:async/zone.dart:1428:13)
#9 _CustomZone.run (dart:async/zone.dart:1328:19)
#10 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1260:23)
#11 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#12 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
#13 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
#14 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
Sample Code
import 'package:flutter/material.dart';
void main() {
runApp(const MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(),
));
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Padding(
padding: EdgeInsets.only(bottom: 20),
child: Text("Please move the mouse quickly between the buttons below."),
),
...List.generate(5, (index) => const Padding(
padding: EdgeInsets.only(top: 10),
child: ItemWidget(),
))
],
),
),
);
}
}
class ItemWidget extends StatefulWidget {
const ItemWidget({Key? key}) : super(key: key);
@override
_ItemWidgetState createState() => _ItemWidgetState();
}
class _ItemWidgetState extends State<ItemWidget> {
bool _showButton = false;
@override
Widget build(BuildContext context) {
return Container(
width: 200,
height: 35,
color: Colors.black38,
padding: const EdgeInsets.all(5),
child: MouseRegion(
onEnter: (e) => setState(() => _showButton = true),
onExit: (e) => setState(() => _showButton = false),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text("Item"),
!_showButton ? Container() : Tooltip(
message: "This is Tooltip message of Button.",
child: SizedBox(
width: 80,
child: ElevatedButton(
onPressed: () {},
child: const Text("Button"),
),
),
)
],
),
),
);
}
}flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-x64, locale zh-Hans-CN)
• Flutter version 2.8.1 at /Users/yowfung/Library/Application Support/fvm/versions/stable
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (5 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/yowfung/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• ANDROID_HOME = /Users/yowfung/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.10.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• 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 11.0.10+0-b96-7281165)
[✓] IntelliJ IDEA Community Edition (version 2021.2.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 63.3.3
• Dart plugin version 212.5632
[✓] VS Code (version 1.57.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.25.0
[✓] Proxy Configuration
• HTTP_PROXY is set
• NO_PROXY is localhost,0.0.0.0,127.0.0.1,192.168.1.145,192.168.3.36,192.168.*,169.254.*
• NO_PROXY contains 127.0.0.1
• NO_PROXY contains localhost
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 12.1 21C52 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.93
• No issues found!bgulmez
Metadata
Metadata
Assignees
Labels
a: mouseIssues related to using a mouse or mouse supportIssues related to using a mouse or mouse supportc: crashStack traces logged to the consoleStack traces logged to the consolef: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 2.8Found to occur in 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9Found to occur in 2.9frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version