Make pumpWidget's arguments named (#141728)

Much nicer calling API and simplifies evolving this API in the future.

I wish we could write a dart fix for this, but that's blocked on https://github.com/dart-lang/sdk/issues/54668.
This commit is contained in:
Michael Goderbauer
2024-01-19 10:29:07 -08:00
committed by GitHub
parent 9e024fdf31
commit cc544169be
20 changed files with 80 additions and 97 deletions

View File

@@ -584,10 +584,10 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// See also [LiveTestWidgetsFlutterBindingFramePolicy], which affects how
/// this method works when the test is run with `flutter run`.
Future<void> pumpWidget(
Widget widget, [
Widget widget, {
Duration? duration,
EnginePhase phase = EnginePhase.sendSemanticsUpdate,
]) {
}) {
return TestAsyncUtils.guard<void>(() {
binding.attachRootWidget(binding.wrapWithDefaultView(widget));
binding.scheduleFrame();

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
@@ -48,7 +49,7 @@ void main() {
_testExecutions.add(execution);
testWidgets(execution.name, experimentalLeakTesting: settings,
(WidgetTester tester) async {
await test.body(tester.pumpWidget, tester.runAsync);
await test.body((Widget widget, [Duration? duration]) => tester.pumpWidget(widget, duration: duration), tester.runAsync);
});
}
}