add missing type parameter on methods (#22096)
This commit is contained in:
committed by
GitHub
parent
48fb726b01
commit
f62afdcf57
@@ -228,7 +228,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
/// Artificially calls dispatchLocaleChanged on the Widget binding,
|
||||
/// then flushes microtasks.
|
||||
Future<Null> setLocale(String languageCode, String countryCode) {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
assert(inTest);
|
||||
final Locale locale = Locale(languageCode, countryCode);
|
||||
dispatchLocaleChanged(locale);
|
||||
@@ -243,7 +243,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
///
|
||||
/// Set to null to use the default surface size.
|
||||
Future<Null> setSurfaceSize(Size size) {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
assert(inTest);
|
||||
if (_surfaceSize == size)
|
||||
return null;
|
||||
@@ -273,7 +273,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
/// to recursively schedule new microtasks. Will not run any timers scheduled
|
||||
/// after this method was invoked, even if they are zero-time timers.
|
||||
Future<Null> idle() {
|
||||
return TestAsyncUtils.guard(() {
|
||||
return TestAsyncUtils.guard<Null>(() {
|
||||
final Completer<Null> completer = Completer<Null>();
|
||||
Timer.run(() {
|
||||
completer.complete(null);
|
||||
@@ -537,7 +537,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
||||
);
|
||||
_parentZone = Zone.current;
|
||||
final Zone testZone = _parentZone.fork(specification: errorHandlingZoneSpecification);
|
||||
testZone.runBinary(_runTestBody, testBody, invariantTester)
|
||||
testZone.runBinary<Future<Null>, Future<Null> Function(), VoidCallback>(_runTestBody, testBody, invariantTester)
|
||||
.whenComplete(testCompletionHandler);
|
||||
timeout?.catchError(handleUncaughtError);
|
||||
return testCompleter.future;
|
||||
@@ -689,7 +689,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
|
||||
|
||||
@override
|
||||
Future<Null> pump([ Duration duration, EnginePhase newPhase = EnginePhase.sendSemanticsUpdate ]) {
|
||||
return TestAsyncUtils.guard(() {
|
||||
return TestAsyncUtils.guard<Null>(() {
|
||||
assert(inTest);
|
||||
assert(_clock != null);
|
||||
if (duration != null)
|
||||
@@ -741,7 +741,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
|
||||
|
||||
addTime(additionalTime);
|
||||
|
||||
return realAsyncZone.run(() {
|
||||
return realAsyncZone.run<Future<T>>(() {
|
||||
_pendingAsyncTasks = Completer<void>();
|
||||
return callback().catchError((dynamic exception, StackTrace stack) {
|
||||
FlutterError.reportError(FlutterErrorDetails(
|
||||
@@ -1197,7 +1197,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
|
||||
assert(inTest);
|
||||
assert(!_expectingFrame);
|
||||
assert(_pendingFrame == null);
|
||||
return TestAsyncUtils.guard(() {
|
||||
return TestAsyncUtils.guard<Null>(() {
|
||||
if (duration != null) {
|
||||
Timer(duration, () {
|
||||
_expectingFrame = true;
|
||||
|
||||
@@ -46,7 +46,7 @@ abstract class WidgetController {
|
||||
Iterable<Widget> get allWidgets {
|
||||
TestAsyncUtils.guardSync();
|
||||
return allElements
|
||||
.map((Element element) => element.widget);
|
||||
.map<Widget>((Element element) => element.widget);
|
||||
}
|
||||
|
||||
/// The matching widget in the widget tree.
|
||||
@@ -137,7 +137,7 @@ abstract class WidgetController {
|
||||
TestAsyncUtils.guardSync();
|
||||
return allElements
|
||||
.whereType<StatefulElement>()
|
||||
.map((StatefulElement element) => element.state);
|
||||
.map<State>((StatefulElement element) => element.state);
|
||||
}
|
||||
|
||||
/// The matching state in the widget tree.
|
||||
@@ -173,7 +173,7 @@ abstract class WidgetController {
|
||||
/// * Use [firstState] if you expect to match several but only want the first.
|
||||
Iterable<T> stateList<T extends State>(Finder finder) {
|
||||
TestAsyncUtils.guardSync();
|
||||
return finder.evaluate().map((Element element) => _stateOf<T>(element, finder));
|
||||
return finder.evaluate().map<T>((Element element) => _stateOf<T>(element, finder));
|
||||
}
|
||||
|
||||
T _stateOf<T extends State>(Element element, Finder finder) {
|
||||
@@ -194,7 +194,7 @@ abstract class WidgetController {
|
||||
Iterable<RenderObject> get allRenderObjects {
|
||||
TestAsyncUtils.guardSync();
|
||||
return allElements
|
||||
.map((Element element) => element.renderObject);
|
||||
.map<RenderObject>((Element element) => element.renderObject);
|
||||
}
|
||||
|
||||
/// The render object of the matching widget in the widget tree.
|
||||
@@ -262,7 +262,7 @@ abstract class WidgetController {
|
||||
|
||||
/// Dispatch a pointer down / pointer up sequence at the given location.
|
||||
Future<Null> tapAt(Offset location, { int pointer }) {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
final TestGesture gesture = await startGesture(location, pointer: pointer);
|
||||
await gesture.up();
|
||||
return null;
|
||||
@@ -293,7 +293,7 @@ abstract class WidgetController {
|
||||
/// Dispatch a pointer down / pointer up sequence at the given location with
|
||||
/// a delay of [kLongPressTimeout] + [kPressTimeout] between the two events.
|
||||
Future<Null> longPressAt(Offset location, { int pointer }) {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
final TestGesture gesture = await startGesture(location, pointer: pointer);
|
||||
await pump(kLongPressTimeout + kPressTimeout);
|
||||
await gesture.up();
|
||||
@@ -371,7 +371,7 @@ abstract class WidgetController {
|
||||
}) {
|
||||
assert(offset.distance > 0.0);
|
||||
assert(speed > 0.0); // speed is pixels/second
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
final TestPointer testPointer = TestPointer(pointer ?? _getNextPointer());
|
||||
final HitTestResult result = hitTestOnBinding(startLocation);
|
||||
const int kMoveCount = 50; // Needs to be >= kHistorySize, see _LeastSquaresVelocityTrackerStrategy
|
||||
@@ -428,7 +428,7 @@ abstract class WidgetController {
|
||||
/// system identifies the gesture as a fling, consider using [flingFrom]
|
||||
/// instead.
|
||||
Future<Null> dragFrom(Offset startLocation, Offset offset, { int pointer }) {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
final TestGesture gesture = await startGesture(startLocation, pointer: pointer);
|
||||
assert(gesture != null);
|
||||
await gesture.moveBy(offset);
|
||||
@@ -469,7 +469,7 @@ abstract class WidgetController {
|
||||
|
||||
/// Forwards the given pointer event to the binding.
|
||||
Future<Null> sendEventToBinding(PointerEvent event, HitTestResult result) {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
binding.dispatchEvent(event, result);
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -633,7 +633,7 @@ class _DescendantFinder extends Finder {
|
||||
@override
|
||||
Iterable<Element> get allCandidates {
|
||||
final Iterable<Element> ancestorElements = ancestor.evaluate();
|
||||
final List<Element> candidates = ancestorElements.expand(
|
||||
final List<Element> candidates = ancestorElements.expand<Element>(
|
||||
(Element element) => collectAllElementsFrom(element, skipOffstage: skipOffstage)
|
||||
).toSet().toList();
|
||||
if (matchRoot)
|
||||
|
||||
@@ -181,7 +181,7 @@ class LocalFileComparator implements GoldenFileComparator {
|
||||
throw test_package.TestFailure('Could not be compared against non-existent file: "$golden"');
|
||||
}
|
||||
final List<int> goldenBytes = await goldenFile.readAsBytes();
|
||||
return _areListsEqual(imageBytes, goldenBytes);
|
||||
return _areListsEqual<int>(imageBytes, goldenBytes);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -142,7 +142,7 @@ class TestGesture {
|
||||
assert(hitTester != null);
|
||||
assert(dispatcher != null);
|
||||
TestGesture result;
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
// dispatch down event
|
||||
final HitTestResult hitTestResult = hitTester(downLocation);
|
||||
final TestPointer testPointer = TestPointer(pointer);
|
||||
@@ -170,7 +170,7 @@ class TestGesture {
|
||||
|
||||
/// Send a move event moving the pointer to the given location.
|
||||
Future<Null> moveTo(Offset location, { Duration timeStamp = Duration.zero }) {
|
||||
return TestAsyncUtils.guard(() {
|
||||
return TestAsyncUtils.guard<Null>(() {
|
||||
assert(_pointer._isDown);
|
||||
return _dispatcher(_pointer.move(location, timeStamp: timeStamp), _result);
|
||||
});
|
||||
@@ -180,7 +180,7 @@ class TestGesture {
|
||||
///
|
||||
/// The object is no longer usable after this method has been called.
|
||||
Future<Null> up() {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
assert(_pointer._isDown);
|
||||
await _dispatcher(_pointer.up(), _result);
|
||||
assert(!_pointer._isDown);
|
||||
@@ -194,7 +194,7 @@ class TestGesture {
|
||||
///
|
||||
/// The object is no longer usable after this method has been called.
|
||||
Future<Null> cancel() {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
assert(_pointer._isDown);
|
||||
await _dispatcher(_pointer.cancel(), _result);
|
||||
assert(!_pointer._isDown);
|
||||
|
||||
@@ -221,7 +221,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
Duration duration,
|
||||
EnginePhase phase = EnginePhase.sendSemanticsUpdate,
|
||||
]) {
|
||||
return TestAsyncUtils.guard(() {
|
||||
return TestAsyncUtils.guard<Null>(() {
|
||||
binding.attachRootWidget(widget);
|
||||
binding.scheduleFrame();
|
||||
return binding.pump(duration, phase);
|
||||
@@ -244,7 +244,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
Duration duration,
|
||||
EnginePhase phase = EnginePhase.sendSemanticsUpdate,
|
||||
]) {
|
||||
return TestAsyncUtils.guard(() => binding.pump(duration, phase));
|
||||
return TestAsyncUtils.guard<Null>(() => binding.pump(duration, phase));
|
||||
}
|
||||
|
||||
/// Repeatedly calls [pump] with the given `duration` until there are no
|
||||
@@ -292,7 +292,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
return true;
|
||||
}());
|
||||
int count = 0;
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
final DateTime endTime = binding.clock.fromNowBy(timeout);
|
||||
do {
|
||||
if (binding.clock.now().isAfter(endTime))
|
||||
@@ -325,7 +325,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
/// [TestFailure] error being thrown.
|
||||
Future<T> runAsync<T>(Future<T> callback(), {
|
||||
Duration additionalTime = const Duration(milliseconds: 250),
|
||||
}) => binding.runAsync(callback, additionalTime: additionalTime);
|
||||
}) => binding.runAsync<T>(callback, additionalTime: additionalTime);
|
||||
|
||||
/// Whether there are any any transient callbacks scheduled.
|
||||
///
|
||||
@@ -351,7 +351,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
|
||||
@override
|
||||
Future<Null> sendEventToBinding(PointerEvent event, HitTestResult result) {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
binding.dispatchEvent(event, result, source: TestBindingEventSource.test);
|
||||
return null;
|
||||
});
|
||||
@@ -485,7 +485,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
/// Does not run timers. May result in an infinite loop or run out of memory
|
||||
/// if microtasks continue to recursively schedule new microtasks.
|
||||
Future<Null> idle() {
|
||||
return TestAsyncUtils.guard(() => binding.idle());
|
||||
return TestAsyncUtils.guard<Null>(() => binding.idle());
|
||||
}
|
||||
|
||||
Set<Ticker> _tickers;
|
||||
@@ -570,8 +570,8 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
/// Tests that just need to add text to widgets like [TextField]
|
||||
/// or [TextFormField] only need to call [enterText].
|
||||
Future<Null> showKeyboard(Finder finder) async {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
final EditableTextState editable = state(
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
final EditableTextState editable = state<EditableTextState>(
|
||||
find.descendant(
|
||||
of: finder,
|
||||
matching: find.byType(EditableText),
|
||||
@@ -593,7 +593,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
/// To just give [finder] the focus without entering any text,
|
||||
/// see [showKeyboard].
|
||||
Future<Null> enterText(Finder finder, String text) async {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<Null>(() async {
|
||||
await showKeyboard(finder);
|
||||
testTextInput.enterText(text);
|
||||
await idle();
|
||||
@@ -605,7 +605,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
|
||||
///
|
||||
/// Will throw an error if there is no back button in the page.
|
||||
Future<void> pageBack() async {
|
||||
return TestAsyncUtils.guard(() async {
|
||||
return TestAsyncUtils.guard<void>(() async {
|
||||
Finder backButton = find.byTooltip('Back');
|
||||
if (backButton.evaluate().isEmpty) {
|
||||
backButton = find.byType(CupertinoNavigationBarBackButton);
|
||||
|
||||
Reference in New Issue
Block a user