- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在编写 Flutter 小部件测试时,我遇到了一个错误,其中在 showModalBottomSheet() 期间创建的 Ticker 没有被处理掉。
我想我明白如果我要实现我自己的 Flutter 动画,我应该制作一个 AnimationController,我会调用 AnimationController.dispose()
在小部件期间 dispose
方法。
然而,由于(我相信) AnimationController 被抽象出来以提供一些便利,我不确定在测试完成后在哪里或如何确保小部件被处理。
注意:代码有效,当我在模拟器/模拟器上进行测试时,模态底部工作表很棒。我只想能够在 testWidgets
中测试它测试。
我看过 showModalBottomSheet 文档 https://api.flutter.dev/flutter/material/showModalBottomSheet.html但这仅显示了如何使用该功能。我没有找到任何方法来控制何时可以处理动画。
test_test.dart
(额外的 pump()
在异步问题的情况下,但它似乎没有帮助)
testWidgets('Taping edit score button brings up bottom sheet to edit',
(WidgetTester tester) async {
setUp();
await tester.pumpWidget(MaterialApp(
home: GameList(
game: Game(players: players),
),
));
await tester.tap(find.byKey(Key('p1-edit-score')));
await tester.pump();
await tester.pump();
expect(find.byKey(Key('test')), findsOneWidget);
await tester.tap(find.byKey(Key('tap-me')));
await tester.pump();
await tester.pump();
tearDown();
});
class GameView extends StatefulWidget {
GameView({@required this.playerList, @required this.onResetPlayerScores});
final Function onResetPlayerScores;
final List<Player> playerList;
@override
_GameState createState() => _GameState();
}
class _GameState extends State<GameView> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(...),
body: GameList(
game: Game(players: widget.playerList),
),
);
}
}
class GameList extends StatefulWidget {
GameList({@required this.game});
final Game game;
@override
GameListState createState() => GameListState(game: game);
}
class GameListState extends State<GameList> {
GameListState({@required this.game});
final Game game;
@override
Widget build(BuildContext context) {
return ListView.separated(
shrinkWrap: true,
itemCount: game.players.length,
itemBuilder: (BuildContext context, int index) {
return Card(
child: Column(
children: <Widget>[
ListTile(
trailing: Text(
'${game.players[index].score.toInt()}',
),
title: Text(
'${game.players[index].name}',
),
),
Row(
children: <Widget>[
FlatButton(
child: Icon(
Icons.edit,
color: Colors.grey[700],
),
onPressed: () async {
_settingModalBottomSheet(context);
},
key: Key(
'${game.players[index].name}-edit-score',
),
),
],
),
],
),
);
},
separatorBuilder: (BuildContext context, int index) => const Divider(),
);
}
}
void _settingModalBottomSheet(context) {
showModalBottomSheet(
context: context,
builder: (BuildContext buildContext) {
return Center(
child: Container(
child: Wrap(
children: <Widget>[
Text(
'edit',
key: Key('test'),
),
ListTile(
leading: Icon(Icons.edit),
title: Text('Video'),
onTap: () {
Navigator.pop(context, 'video');
},
key: Key('tap-me'),
),
],
),
),
);
},
);
}
flutter test
的短输出.我认为最重要的部分。
OverlayState created a Ticker via its TickerProviderStateMixin, but at the time dispose() was called
on the mixin, that Ticker was still active. All Tickers must be disposed before calling
super.dispose(). Tickers used by AnimationControllers should be disposed by calling dispose() on the
AnimationController itself. Otherwise, the ticker will leak.
flutter test
的完整输出
The following assertion was thrown while finalizing the widget tree:
OverlayState#bfe06(tickers: tracking 1 ticker, entries: [OverlayEntry#c26ee(opaque: false;
maintainState: false), OverlayEntry#7cd4f(opaque: false; maintainState: true),
OverlayEntry#d496e(opaque: false; maintainState: false), OverlayEntry#e9ad3(opaque: false;
maintainState: true)]) was disposed with an active Ticker.
OverlayState created a Ticker via its TickerProviderStateMixin, but at the time dispose() was called
on the mixin, that Ticker was still active. All Tickers must be disposed before calling
super.dispose(). Tickers used by AnimationControllers should be disposed by calling dispose() on the
AnimationController itself. Otherwise, the ticker will leak.
The offending ticker was: _WidgetTicker(created by OverlayState#bfe06(tickers: tracking 0 tickers,
entries: [OverlayEntry#c26ee(opaque: false; maintainState: false), OverlayEntry#7cd4f(opaque: false;
maintainState: true)]))
The stack trace when the _WidgetTicker was actually created was:
#0 new Ticker.<anonymous closure> (package:flutter/src/scheduler/ticker.dart:64:40)
#1 new Ticker (package:flutter/src/scheduler/ticker.dart:66:6)
#2 new _WidgetTicker (package:flutter/src/widgets/ticker_provider.dart:225:80)
#3 _OverlayState&State&TickerProviderStateMixin.createTicker
(package:flutter/src/widgets/ticker_provider.dart:161:34)
#4 new AnimationController (package:flutter/src/animation/animation_controller.dart:245:21)
#5 BottomSheet.createAnimationController
(package:flutter/src/material/bottom_sheet.dart:128:12)
#6 _ModalBottomSheetRoute.createAnimationController
(package:flutter/src/material/bottom_sheet.dart:356:40)
#7 TransitionRoute.install (package:flutter/src/widgets/routes.dart:176:19)
#8 ModalRoute.install (package:flutter/src/widgets/routes.dart:907:11)
#9 NavigatorState.push (package:flutter/src/widgets/navigator.dart:1754:11)
#10 Navigator.push (package:flutter/src/widgets/navigator.dart:1093:34)
#11 showModalBottomSheet (package:flutter/src/material/bottom_sheet.dart:427:20)
#12 _settingModalBottomSheet (package:score_keeper/game_list.dart:98:3)
#13 GameListState.build.<anonymous closure>.<anonymous closure>
(package:score_keeper/game_list.dart:65:23)
<asynchronous suspension>
#14 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:635:14)
#15 _InkResponseState.build.<anonymous closure>
(package:flutter/src/material/ink_well.dart:711:32)
#16 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#17 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
#18 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:312:7)
#19 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
#20
_TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding&GestureBinding.handleEvent
(package:flutter/src/gestures/binding.dart:222:20)
#21
_TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding&GestureBinding.dispatchEvent
(package:flutter/src/gestures/binding.dart:198:22)
#22 TestWidgetsFlutterBinding.dispatchEvent (package:flutter_test/src/binding.dart:365:11)
#23 WidgetTester.sendEventToBinding.<anonymous closure>
(package:flutter_test/src/widget_tester.dart:458:15)
#25 WidgetTester.sendEventToBinding.<anonymous closure>
(package:flutter_test/src/widget_tester.dart:457:39)
#28 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:69:41)
#29 WidgetTester.sendEventToBinding (package:flutter_test/src/widget_tester.dart:457:27)
#30 TestGesture.up.<anonymous closure> (package:flutter_test/src/test_pointer.dart:422:13)
#32 TestGesture.up.<anonymous closure> (package:flutter_test/src/test_pointer.dart:420:39)
#35 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:69:41)
#36 TestGesture.up (package:flutter_test/src/test_pointer.dart:420:27)
#37 WidgetController.tapAt.<anonymous closure> (package:flutter_test/src/controller.dart:263:21)
#51 WidgetController.startGesture (package:flutter_test/src/controller.dart)
#75 AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure>
(package:flutter_test/src/binding.dart:1026:17)
#77 AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure>
(package:flutter_test/src/binding.dart:1014:35)
(elided 58 frames from class _FakeAsync, package dart:async, package dart:async-patch, and package
stack_trace)
When the exception was thrown, this was the stack:
#0 _OverlayState&State&TickerProviderStateMixin.dispose.<anonymous closure> (package:flutter/src/widgets/ticker_provider.dart:178:13)
#1 _OverlayState&State&TickerProviderStateMixin.dispose (package:flutter/src/widgets/ticker_provider.dart:191:6)
#2 StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4107:12)
#3 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1737:13)
#4 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#5 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#6 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#7 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#8 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#9 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#10 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#11 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#12 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#13 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#14 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#15 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#16 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#17 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#18 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#19 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#20 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#21 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#22 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#23 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#24 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#25 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#26 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#27 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#28 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#29 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#30 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#31 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#32 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#33 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#34 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#35 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#36 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#37 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#38 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#39 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#40 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#41 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#42 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#43 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#44 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#45 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#46 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#47 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#48 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#49 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#50 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#51 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#52 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#53 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#54 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#55 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#56 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#57 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#58 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#59 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#60 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#61 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#62 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#63 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#64 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#65 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#66 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#67 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#68 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5080:14)
#69 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#70 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#71 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#72 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#73 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#74 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#75 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#76 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#77 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#78 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#79 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#80 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#81 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#82 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#83 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#84 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#85 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1735:7)
#86 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3955:14)
#87 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1733:13)
#88 ListIterable.forEach (dart:_internal/iterable.dart:39:13)
#89 _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1746:25)
#90 BuildOwner.finalizeTree.<anonymous closure> (package:flutter/src/widgets/framework.dart:2426:27)
#91 BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2258:15)
#92 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2425:7)
#93 AutomatedTestWidgetsFlutterBinding.drawFrame (package:flutter_test/src/binding.dart:953:18)
#94 _TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding&GestureBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5)
#95 _TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1016:15)
#96 _TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:958:9)
#97 AutomatedTestWidgetsFlutterBinding.scheduleWarmUpFrame (package:flutter_test/src/binding.dart:915:5)
#98 runApp (package:flutter/src/widgets/binding.dart:787:7)
#99 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:637:7)
<asynchronous suspension>
#102 TestWidgetsFlutterBinding._runTest (package:flutter_test/src/binding.dart:613:14)
#103 AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:1010:24)
#109 AutomatedTestWidgetsFlutterBinding.runTest (package:flutter_test/src/binding.dart:1007:15)
#110 testWidgets.<anonymous closure> (package:flutter_test/src/widget_tester.dart:116:22)
#111 Declarer.test.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:168:27)
<asynchronous suspension>
#112 Invoker.waitForOutstandingCallbacks.<anonymous closure> (package:test_api/src/backend/invoker.dart:250:15)
<asynchronous suspension>
#117 Invoker.waitForOutstandingCallbacks (package:test_api/src/backend/invoker.dart:247:5)
#118 Declarer.test.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/declarer.dart:166:33)
#123 Declarer.test.<anonymous closure> (package:test_api/src/backend/declarer.dart:165:13)
<asynchronous suspension>
#124 Invoker._onRun.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/backend/invoker.dart:400:25)
<asynchronous suspension>
#138 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
#139 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#140 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
(elided 28 frames from class _FakeAsync, package dart:async, package dart:async-patch, and package stack_trace)
════════════════════════════════════════════════════════════════════════════════════════════════════
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following message was thrown:
An animation is still running even after the widget tree was disposed.
There was one transient callback left. The stack trace for when it was registered is as follows:
── callback 72 ──
#0 new _FrameCallbackEntry.<anonymous closure> (package:flutter/src/scheduler/binding.dart:112:33)
#1 new _FrameCallbackEntry (package:flutter/src/scheduler/binding.dart:115:6)
#2 _TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding.scheduleFrameCallback (package:flutter/src/scheduler/binding.dart:459:49)
#3 Ticker.scheduleTick (package:flutter/src/scheduler/ticker.dart:243:46)
#4 Ticker.start (package:flutter/src/scheduler/ticker.dart:159:7)
#5 AnimationController._startSimulation (package:flutter/src/animation/animation_controller.dart:685:41)
#6 AnimationController._animateToInternal (package:flutter/src/animation/animation_controller.dart:590:12)
#7 AnimationController.forward (package:flutter/src/animation/animation_controller.dart:458:12)
#8 TransitionRoute.didPush (package:flutter/src/widgets/routes.dart:188:24)
#9 ModalRoute.didPush (package:flutter/src/widgets/routes.dart:917:18)
#10 NavigatorState.push (package:flutter/src/widgets/navigator.dart:1756:11)
#11 Navigator.push (package:flutter/src/widgets/navigator.dart:1093:34)
#12 showModalBottomSheet (package:flutter/src/material/bottom_sheet.dart:427:20)
#13 _settingModalBottomSheet (package:score_keeper/game_list.dart:98:3)
#14 GameListState.build.<anonymous closure>.<anonymous closure> (package:score_keeper/game_list.dart:65:23)
<asynchronous suspension>
#15 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:635:14)
#16 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:711:32)
#17 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#18 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
#19 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:312:7)
#20 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
#21 _TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
#22 _TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
#23 TestWidgetsFlutterBinding.dispatchEvent (package:flutter_test/src/binding.dart:365:11)
#24 WidgetTester.sendEventToBinding.<anonymous closure> (package:flutter_test/src/widget_tester.dart:458:15)
#26 WidgetTester.sendEventToBinding.<anonymous closure> (package:flutter_test/src/widget_tester.dart:457:39)
#29 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:69:41)
#30 WidgetTester.sendEventToBinding (package:flutter_test/src/widget_tester.dart:457:27)
#31 TestGesture.up.<anonymous closure> (package:flutter_test/src/test_pointer.dart:422:13)
#33 TestGesture.up.<anonymous closure> (package:flutter_test/src/test_pointer.dart:420:39)
#36 TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:69:41)
#37 TestGesture.up (package:flutter_test/src/test_pointer.dart:420:27)
#38 WidgetController.tapAt.<anonymous closure> (package:flutter_test/src/controller.dart:263:21)
#52 WidgetController.startGesture (package:flutter_test/src/controller.dart)
#76 AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:1026:17)
#78 AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:1014:35)
(elided 58 frames from class _FakeAsync, package dart:async, package dart:async-patch, and package stack_trace)
════════════════════════════════════════════════════════════════════════════════════════════════════
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following message was thrown:
Multiple exceptions (2) were detected during the running of the current test, and at least one was
unexpected.
════════════════════════════════════════════════════════════════════════════════════════════════════
00:04 +25 -1: /Users/tsustare/src/projects/flutter-score-keeper/score_keeper/test/game_view_test.dart: Taping edit score button brings up bottom sheet to edit [E]
Test failed. See exception logs above.
The test description was: Taping edit score button brings up bottom sheet to edit```
最佳答案
尝试点击底部工作表中没有的任何可见小部件并在测试结束前触发一个框架。这将关闭底部工作表并处理它的 AnimationContoller
在测试退出之前。
例如在测试结束时:
await tester.tap(find.byType(BackButtonIcon)); // any widget that isn't in the bottom sheet
await tester.pump();
关于Flutter `showModalBottomSheet` Ticker 在测试期间没有被处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57580244/
showModalBottomSheet不会弹出模式。我不熟悉 Dart ,但是我认为这是一个问题,我没有任何帮助。在下面弹出底部工作表模式的简单页面无效。 ``` import 'package
如何在底部工作表模式中禁用/避免向下拖动手势,以便用户可以在模式中进行交互而不会意外关闭模式? 在下方更新了实际的模态底页。 return showModalBottomSheet( cont
是否有可能阻止 ModalBottomSheet 对外部触摸隐藏?就像在 showDialog() 中一样,我们可以使用 barrierDismissible property to prevent
正如标题所说,当 showModalBottomSheet 出现时,我想在主体/屏幕中按下某个按钮而不关闭我已经设置的 showModalBottomSheet isDismissible: fals
我试图让 showModalBottomSheet() 的高度自动适应内容。 我使用了 FractionallySizedBox 和 isScrollControlled: true 但它需要提供 h
在我的应用程序中,我正在尝试实现类似 Badoo 的排序/过滤 showBottomModalSheet 功能。我设法创建了 2 个单独的页面,我可以在它们之间来回导航。但是,我面临的问题是 show
在编写 Flutter 小部件测试时,我遇到了一个错误,其中在 showModalBottomSheet() 期间创建的 Ticker 没有被处理掉。 我想我明白如果我要实现我自己的 Flutter
我们无法更新小部件状态的 BottomSheet 是否有任何限制?正如您在下面的示例中所看到的,我使用的是 Switch,但它的显示没有改变,虽然值更新了,只是它不会再次重新渲染。 现在这是 Stat
我使用 showRoundedModalBottomSheet,如何调整此模态高度直到 appbar? 最佳答案 [更新] 在showModalBottomSheet(...)中设置属性isScrol
我正在使用 showModalBottomSheet 小部件,我想更改大小以使其占据大约 75% 的屏幕(默认情况下它似乎占据 50%)。我试图按照文档进行操作,但找不到大小属性。有人可以建议我一种更
对于 showModalBottomSheet,我想在它周围显示边距。主要是左右。这样它看起来会与屏幕两侧分开。如何实现。另外,如果我想在底部提供边距,如何实现。是否有任何其他小部件提供与 modal
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 2 年前。 Improve this qu
我试着这样写 showModalBottomSheet( context: context, // I got error here (Undefined name 'context'.dart
我有一个 showModalBottomSheet如下所示,据我所知继承自 BottomSheet (对?) showModalBottomSheet( context:
我有设计(如图所示)并且我正在使用 showModalBottomSheet 但是当我设置宽度时,它不会改变并保持为屏幕宽度,所以我有几个问题: 1-如何给showModalBottomSheet设置
我是 Flutter 的新手,我一直在尝试创建一个底部工作表,当您单击 float 操作按钮时它会打开。我遵循了很多关于如何做的教程,它们都显示了相同的东西,但每当我尝试实现它时,我就是不起作用,而是
我有一个名为 testWidget 的小部件,它有两个子部件:一个 TextField 和一个 FlatButton。 当用户按下 FlatButton 时,我想对 TextField 中键入的文本执
我在小部件树中有一个 FloatingActionButton,它有一个 BlocProvider来自 flutter_bloc .像这样: BlocProvider( builder: (con
我启动一个模态底部工作表,然后使用返回的数据作为它的 future 。 var modalFuture = showModalBottomSheet( // ...
在我的应用程序中,我使用 2 个 Material 应用程序来处理底部导航栏的导航。 由于我的应用程序非常复杂,这是最好的方法。 在一个屏幕上,当用户未登录时,将打开一个底部表单,用户可以在其中输入他
我是一名优秀的程序员,十分优秀!