From 7b251f5f37b2b10334752da6bed1f5b136f0cb4b Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 4 Mar 2021 08:59:17 -0800 Subject: [PATCH] Enable use_function_type_syntax_for_parameters lint (#77163) --- analysis_options.yaml | 2 +- .../macrobenchmarks/test_driver/util.dart | 4 ++-- dev/bots/test/fake_process_manager.dart | 2 +- dev/devicelab/lib/framework/apk_utils.dart | 6 ++--- dev/devicelab/lib/framework/utils.dart | 4 ++-- .../lib/demo/material/data_table_demo.dart | 4 ++-- .../test/example_code_parser_test.dart | 2 +- .../flutter_gallery/test/live_smoketest.dart | 2 +- dev/manual_tests/lib/card_collection.dart | 2 +- dev/tools/dartdoc.dart | 2 +- .../lib/src/foundation/basic_types.dart | 10 ++++----- .../flutter/lib/src/foundation/binding.dart | 2 +- .../flutter/lib/src/foundation/debug.dart | 2 +- .../src/foundation/synchronous_future.dart | 8 +++---- .../flutter/lib/src/material/theme_data.dart | 2 +- packages/flutter/lib/src/painting/clip.dart | 10 ++++----- .../flutter/lib/src/painting/image_cache.dart | 2 +- packages/flutter/lib/src/rendering/box.dart | 6 ++--- packages/flutter/lib/src/rendering/stack.dart | 2 +- .../flutter/lib/src/scheduler/ticker.dart | 4 ++-- .../lib/src/services/asset_bundle.dart | 6 ++--- .../lib/src/services/platform_channel.dart | 2 +- .../lib/src/services/text_formatter.dart | 2 +- packages/flutter/lib/src/widgets/actions.dart | 2 +- .../flutter/lib/src/widgets/framework.dart | 6 ++--- .../lib/src/widgets/widget_inspector.dart | 8 +++---- packages/flutter/test/_goldens_web.dart | 2 +- .../flutter/test/flutter_test_config.dart | 2 +- .../test/material/date_picker_test.dart | 2 +- .../test/material/date_range_picker_test.dart | 2 +- .../flutter/test/material/scaffold_test.dart | 2 +- .../flutter/test/rendering/layers_test.dart | 2 +- .../test/scheduler/scheduler_test.dart | 2 +- ...widget_inspector_structure_error_test.dart | 2 +- .../lib/src/common/handler_factory.dart | 2 +- .../flutter_driver/lib/src/driver/driver.dart | 4 ++-- .../lib/src/driver/timeline_summary.dart | 2 +- .../lib/src/driver/vmservice_driver.dart | 4 ++-- .../flutter_goldens/lib/flutter_goldens.dart | 2 +- .../test/flutter_goldens_test.dart | 8 +++---- packages/flutter_test/lib/src/binding.dart | 22 +++++++++---------- packages/flutter_test/lib/src/controller.dart | 2 +- packages/flutter_test/lib/src/matchers.dart | 2 +- .../lib/src/test_async_utils.dart | 2 +- .../flutter_test/lib/src/widget_tester.dart | 2 +- .../flutter_test_config.dart | 2 +- packages/flutter_test/test/goldens_test.dart | 2 +- .../test/test_config/flutter_test_config.dart | 2 +- .../nested_config/flutter_test_config.dart | 2 +- packages/flutter_tools/lib/runner.dart | 2 +- .../flutter_tools/lib/src/base/context.dart | 2 +- .../lib/src/base/file_system.dart | 4 ++-- .../lib/src/build_system/build_system.dart | 2 +- .../lib/src/commands/daemon.dart | 2 +- .../lib/src/commands/update_packages.dart | 2 +- .../flutter_tools/lib/src/context_runner.dart | 2 +- .../flutter_tools/lib/src/ios/xcodeproj.dart | 2 +- .../lib/src/reporting/crash_reporting.dart | 2 +- .../lib/src/test/flutter_tester_device.dart | 2 +- .../android/android_device_test.dart | 6 ++--- .../general.shard/android/gradle_test.dart | 2 +- .../test/general.shard/base/logger_test.dart | 2 +- .../general.shard/ios/xcodeproj_test.dart | 2 +- .../test/general.shard/project_test.dart | 8 +++---- packages/flutter_tools/test/src/common.dart | 4 ++-- packages/flutter_tools/test/src/context.dart | 2 +- .../lib/src/fuchsia_remote_connection.dart | 2 +- .../lib/integration_test.dart | 8 +++---- 68 files changed, 119 insertions(+), 119 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index ef0e53f093..5eb60fd68f 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -214,7 +214,7 @@ linter: - unrelated_type_equality_checks # - unsafe_html # not yet tested - use_full_hex_values_for_flutter_colors - # - use_function_type_syntax_for_parameters # not yet tested + - use_function_type_syntax_for_parameters # - use_if_null_to_convert_nulls_to_bools # not yet tested - use_is_even_rather_than_modulo - use_key_in_widget_constructors diff --git a/dev/benchmarks/macrobenchmarks/test_driver/util.dart b/dev/benchmarks/macrobenchmarks/test_driver/util.dart index b126f30a7f..adf819dc9c 100644 --- a/dev/benchmarks/macrobenchmarks/test_driver/util.dart +++ b/dev/benchmarks/macrobenchmarks/test_driver/util.dart @@ -40,8 +40,8 @@ void macroPerfTest( { Duration pageDelay, Duration duration = const Duration(seconds: 3), Duration timeout = kTimeout, - Future driverOps(FlutterDriver driver), - Future setupOps(FlutterDriver driver), + Future Function(FlutterDriver driver) driverOps, + Future Function(FlutterDriver driver) setupOps, }) { test(testName, () async { Timeline timeline; diff --git a/dev/bots/test/fake_process_manager.dart b/dev/bots/test/fake_process_manager.dart index e4c50329b9..84e7ad7408 100644 --- a/dev/bots/test/fake_process_manager.dart +++ b/dev/bots/test/fake_process_manager.dart @@ -115,7 +115,7 @@ class FakeProcessManager extends Mock implements ProcessManager { /// A fake process that can be used to interact with a process "started" by the FakeProcessManager. class FakeProcess extends Mock implements Process { - FakeProcess(ProcessResult result, {void stdinResults(String input)}) + FakeProcess(ProcessResult result, {void Function(String input) stdinResults}) : stdoutStream = Stream>.value((result.stdout as String).codeUnits), stderrStream = Stream>.value((result.stderr as String).codeUnits), desiredExitCode = result.exitCode, diff --git a/dev/devicelab/lib/framework/apk_utils.dart b/dev/devicelab/lib/framework/apk_utils.dart index e6bc520c7a..b9fd7b238b 100644 --- a/dev/devicelab/lib/framework/apk_utils.dart +++ b/dev/devicelab/lib/framework/apk_utils.dart @@ -30,7 +30,7 @@ final List baseApkFiles = [ ]; /// Runs the given [testFunction] on a freshly generated Flutter project. -Future runProjectTest(Future testFunction(FlutterProject project)) async { +Future runProjectTest(Future Function(FlutterProject project) testFunction) async { final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_plugin_test.'); final FlutterProject project = await FlutterProject.create(tempDir, 'hello'); @@ -42,7 +42,7 @@ Future runProjectTest(Future testFunction(FlutterProject project)) a } /// Runs the given [testFunction] on a freshly generated Flutter plugin project. -Future runPluginProjectTest(Future testFunction(FlutterPluginProject pluginProject)) async { +Future runPluginProjectTest(Future Function(FlutterPluginProject pluginProject) testFunction) async { final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_plugin_test.'); final FlutterPluginProject pluginProject = await FlutterPluginProject.create(tempDir, 'aaa'); @@ -54,7 +54,7 @@ Future runPluginProjectTest(Future testFunction(FlutterPluginProject } /// Runs the given [testFunction] on a freshly generated Flutter module project. -Future runModuleProjectTest(Future testFunction(FlutterModuleProject moduleProject)) async { +Future runModuleProjectTest(Future Function(FlutterModuleProject moduleProject) testFunction) async { final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_module_test.'); final FlutterModuleProject moduleProject = await FlutterModuleProject.create(tempDir, 'hello_module'); diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart index 5319724f56..21a96e97ad 100644 --- a/dev/devicelab/lib/framework/utils.dart +++ b/dev/devicelab/lib/framework/utils.dart @@ -514,7 +514,7 @@ Future findJavaHome() async { return path.dirname(path.dirname(javaBinary)); } -Future inDirectory(dynamic directory, Future action()) async { +Future inDirectory(dynamic directory, Future Function() action) async { final String previousCwd = cwd; try { cd(directory); @@ -629,7 +629,7 @@ Iterable grep(Pattern pattern, {@required String from}) { /// } catch (error, chain) { /// /// } -Future runAndCaptureAsyncStacks(Future callback()) { +Future runAndCaptureAsyncStacks(Future Function() callback) { final Completer completer = Completer(); Chain.capture(() async { await callback(); diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/data_table_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/data_table_demo.dart index 632e47facb..71fe839c2f 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/data_table_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/data_table_demo.dart @@ -78,7 +78,7 @@ class DessertDataSource extends DataTableSource { Dessert('Coconut slice and KitKat', 677, 41.0, 72, 8.5, 63, 12, 12), ]; - void _sort(Comparable getField(Dessert d), bool ascending) { + void _sort(Comparable Function(Dessert d) getField, bool ascending) { _desserts.sort((Dessert a, Dessert b) { if (!ascending) { final Dessert c = a; @@ -156,7 +156,7 @@ class _DataTableDemoState extends State { bool _sortAscending = true; final DessertDataSource _dessertsDataSource = DessertDataSource(); - void _sort(Comparable getField(Dessert d), int columnIndex, bool ascending) { + void _sort(Comparable Function(Dessert d) getField, int columnIndex, bool ascending) { _dessertsDataSource._sort(getField, ascending); setState(() { _sortColumnIndex = columnIndex; diff --git a/dev/integration_tests/flutter_gallery/test/example_code_parser_test.dart b/dev/integration_tests/flutter_gallery/test/example_code_parser_test.dart index ef4ec9c5b6..18700928f4 100644 --- a/dev/integration_tests/flutter_gallery/test/example_code_parser_test.dart +++ b/dev/integration_tests/flutter_gallery/test/example_code_parser_test.dart @@ -53,7 +53,7 @@ class TestAssetBundle extends AssetBundle { } @override - Future loadStructuredData(String key, Future parser(String value)) async { + Future loadStructuredData(String key, Future Function(String value) parser) async { return parser(await loadString(key)); } diff --git a/dev/integration_tests/flutter_gallery/test/live_smoketest.dart b/dev/integration_tests/flutter_gallery/test/live_smoketest.dart index 6b83d78b08..f7980addeb 100644 --- a/dev/integration_tests/flutter_gallery/test/live_smoketest.dart +++ b/dev/integration_tests/flutter_gallery/test/live_smoketest.dart @@ -109,7 +109,7 @@ class _LiveWidgetController extends LiveWidgetController { bool frameSync = true; /// Waits until at the end of a frame the provided [condition] is [true]. - Future _waitUntilFrame(bool condition(), [Completer? completer]) { + Future _waitUntilFrame(bool Function() condition, [Completer? completer]) { completer ??= Completer(); if (!condition()) { SchedulerBinding.instance!.addPostFrameCallback((Duration timestamp) { diff --git a/dev/manual_tests/lib/card_collection.dart b/dev/manual_tests/lib/card_collection.dart index 372e28942e..5eebeeaab5 100644 --- a/dev/manual_tests/lib/card_collection.dart +++ b/dev/manual_tests/lib/card_collection.dart @@ -182,7 +182,7 @@ class CardCollectionState extends State { }); } - Widget buildDrawerCheckbox(String label, bool value, void callback(), { bool enabled = true }) { + Widget buildDrawerCheckbox(String label, bool value, void Function() callback, { bool enabled = true }) { return ListTile( onTap: enabled ? callback : null, title: Text(label), diff --git a/dev/tools/dartdoc.dart b/dev/tools/dartdoc.dart index 7f55fd8de2..ca50839269 100644 --- a/dev/tools/dartdoc.dart +++ b/dev/tools/dartdoc.dart @@ -313,7 +313,7 @@ void createSearchMetadata(String templatePath, String metadataPath) { /// specified, for each source/destination file pair. /// /// Creates `destDir` if needed. -void copyDirectorySync(Directory srcDir, Directory destDir, [void onFileCopied(File srcFile, File destFile)]) { +void copyDirectorySync(Directory srcDir, Directory destDir, [void Function(File srcFile, File destFile) onFileCopied]) { if (!srcDir.existsSync()) throw Exception('Source directory "${srcDir.path}" does not exist, nothing to copy'); diff --git a/packages/flutter/lib/src/foundation/basic_types.dart b/packages/flutter/lib/src/foundation/basic_types.dart index 40d3e6af36..f345244d09 100644 --- a/packages/flutter/lib/src/foundation/basic_types.dart +++ b/packages/flutter/lib/src/foundation/basic_types.dart @@ -136,17 +136,17 @@ class CachingIterable extends IterableBase { } @override - Iterable map(T f(E e)) { + Iterable map(T Function(E e) f) { return CachingIterable(super.map(f).iterator); } @override - Iterable where(bool test(E element)) { + Iterable where(bool Function(E element) test) { return CachingIterable(super.where(test).iterator); } @override - Iterable expand(Iterable f(E element)) { + Iterable expand(Iterable Function(E element) f) { return CachingIterable(super.expand(f).iterator); } @@ -156,7 +156,7 @@ class CachingIterable extends IterableBase { } @override - Iterable takeWhile(bool test(E value)) { + Iterable takeWhile(bool Function(E value) test) { return CachingIterable(super.takeWhile(test).iterator); } @@ -166,7 +166,7 @@ class CachingIterable extends IterableBase { } @override - Iterable skipWhile(bool test(E value)) { + Iterable skipWhile(bool Function(E value) test) { return CachingIterable(super.skipWhile(test).iterator); } diff --git a/packages/flutter/lib/src/foundation/binding.dart b/packages/flutter/lib/src/foundation/binding.dart index f6287b2465..97a9237d69 100644 --- a/packages/flutter/lib/src/foundation/binding.dart +++ b/packages/flutter/lib/src/foundation/binding.dart @@ -290,7 +290,7 @@ abstract class BindingBase { /// /// The [Future] returned by the `callback` argument is returned by [lockEvents]. @protected - Future lockEvents(Future callback()) { + Future lockEvents(Future Function() callback) { developer.Timeline.startSync('Lock events'); assert(callback != null); diff --git a/packages/flutter/lib/src/foundation/debug.dart b/packages/flutter/lib/src/foundation/debug.dart index 5fc406ac83..22cbabe3e6 100644 --- a/packages/flutter/lib/src/foundation/debug.dart +++ b/packages/flutter/lib/src/foundation/debug.dart @@ -51,7 +51,7 @@ bool debugInstrumentationEnabled = false; /// * [Timeline], which is used to record synchronous tracing events for /// visualization in Chrome's tracing format. This method does not /// implicitly add any timeline events. -Future debugInstrumentAction(String description, Future action()) async { +Future debugInstrumentAction(String description, Future Function() action) async { bool instrument = false; assert(() { instrument = debugInstrumentationEnabled; diff --git a/packages/flutter/lib/src/foundation/synchronous_future.dart b/packages/flutter/lib/src/foundation/synchronous_future.dart index 9182fbd424..4f853ed41d 100644 --- a/packages/flutter/lib/src/foundation/synchronous_future.dart +++ b/packages/flutter/lib/src/foundation/synchronous_future.dart @@ -34,10 +34,10 @@ class SynchronousFuture implements Future { } @override - Future catchError(Function onError, { bool test(Object error)? }) => Completer().future; + Future catchError(Function onError, { bool Function(Object error)? test }) => Completer().future; @override - Future then(FutureOr onValue(T value), { Function? onError }) { + Future then(FutureOr Function(T value) onValue, { Function? onError }) { final dynamic result = onValue(_value); if (result is Future) return result; @@ -45,12 +45,12 @@ class SynchronousFuture implements Future { } @override - Future timeout(Duration timeLimit, { FutureOr onTimeout()? }) { + Future timeout(Duration timeLimit, { FutureOr Function()? onTimeout }) { return Future.value(_value).timeout(timeLimit, onTimeout: onTimeout); } @override - Future whenComplete(FutureOr action()) { + Future whenComplete(FutureOr Function() action) { try { final FutureOr result = action(); if (result is Future) diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 14ef3cd74d..b6611efd73 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -1978,7 +1978,7 @@ class _FifoCache { /// if not, calls the given callback to obtain it first. /// /// The arguments must not be null. - V putIfAbsent(K key, V loader()) { + V putIfAbsent(K key, V Function() loader) { assert(key != null); assert(loader != null); final V? result = _cache[key]; diff --git a/packages/flutter/lib/src/painting/clip.dart b/packages/flutter/lib/src/painting/clip.dart index 808a5e72a2..0934c0a269 100644 --- a/packages/flutter/lib/src/painting/clip.dart +++ b/packages/flutter/lib/src/painting/clip.dart @@ -3,14 +3,14 @@ // found in the LICENSE file. -import 'dart:ui' show Canvas, Clip, Path, Paint, Rect, RRect; +import 'dart:ui' show Canvas, Clip, Path, Paint, Rect, RRect, VoidCallback; /// Clip utilities used by [PaintingContext]. abstract class ClipContext { /// The canvas on which to paint. Canvas get canvas; - void _clipAndPaint(void canvasClipCall(bool doAntiAlias), Clip clipBehavior, Rect bounds, void painter()) { + void _clipAndPaint(void Function(bool doAntiAlias) canvasClipCall, Clip clipBehavior, Rect bounds, VoidCallback painter) { assert(canvasClipCall != null); canvas.save(); switch (clipBehavior) { @@ -38,7 +38,7 @@ abstract class ClipContext { /// restored to the pre-clip status afterwards. /// /// `bounds` is the saveLayer bounds used for [Clip.antiAliasWithSaveLayer]. - void clipPathAndPaint(Path path, Clip clipBehavior, Rect bounds, void painter()) { + void clipPathAndPaint(Path path, Clip clipBehavior, Rect bounds, VoidCallback painter) { _clipAndPaint((bool doAntiAias) => canvas.clipPath(path, doAntiAlias: doAntiAias), clipBehavior, bounds, painter); } @@ -46,7 +46,7 @@ abstract class ClipContext { /// restored to the pre-clip status afterwards. /// /// `bounds` is the saveLayer bounds used for [Clip.antiAliasWithSaveLayer]. - void clipRRectAndPaint(RRect rrect, Clip clipBehavior, Rect bounds, void painter()) { + void clipRRectAndPaint(RRect rrect, Clip clipBehavior, Rect bounds, VoidCallback painter) { _clipAndPaint((bool doAntiAias) => canvas.clipRRect(rrect, doAntiAlias: doAntiAias), clipBehavior, bounds, painter); } @@ -54,7 +54,7 @@ abstract class ClipContext { /// restored to the pre-clip status afterwards. /// /// `bounds` is the saveLayer bounds used for [Clip.antiAliasWithSaveLayer]. - void clipRectAndPaint(Rect rect, Clip clipBehavior, Rect bounds, void painter()) { + void clipRectAndPaint(Rect rect, Clip clipBehavior, Rect bounds, VoidCallback painter) { _clipAndPaint((bool doAntiAias) => canvas.clipRect(rect, doAntiAlias: doAntiAias), clipBehavior, bounds, painter); } } diff --git a/packages/flutter/lib/src/painting/image_cache.dart b/packages/flutter/lib/src/painting/image_cache.dart index 2288415d28..7568b67c8b 100644 --- a/packages/flutter/lib/src/painting/image_cache.dart +++ b/packages/flutter/lib/src/painting/image_cache.dart @@ -314,7 +314,7 @@ class ImageCache { /// `onError` is also provided. When an exception is caught resolving an image, /// no completers are cached and `null` is returned instead of a new /// completer. - ImageStreamCompleter? putIfAbsent(Object key, ImageStreamCompleter loader(), { ImageErrorListener? onError }) { + ImageStreamCompleter? putIfAbsent(Object key, ImageStreamCompleter Function() loader, { ImageErrorListener? onError }) { assert(key != null); assert(loader != null); TimelineTask? timelineTask; diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index 2975bd7b32..7aed6f7c6e 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -1360,7 +1360,7 @@ abstract class RenderBox extends RenderObject { Map<_IntrinsicDimensionsCacheEntry, double>? _cachedIntrinsicDimensions; - double _computeIntrinsicDimension(_IntrinsicDimension dimension, double argument, double computer(double argument)) { + double _computeIntrinsicDimension(_IntrinsicDimension dimension, double argument, double Function(double argument) computer) { assert(RenderObject.debugCheckingIntrinsics || !debugDoingThisResize); // performResize should not depend on anything except the incoming constraints bool shouldCache = true; assert(() { @@ -2238,7 +2238,7 @@ abstract class RenderBox extends RenderObject { RenderObject.debugCheckingIntrinsics = true; final List failures = []; - double testIntrinsic(double function(double extent), String name, double constraint) { + double testIntrinsic(double Function(double extent) function, String name, double constraint) { final double result = function(constraint); if (result < 0) { failures.add(ErrorDescription(' * $name($constraint) returned a negative value: $result')); @@ -2249,7 +2249,7 @@ abstract class RenderBox extends RenderObject { return result; } - void testIntrinsicsForValues(double getMin(double extent), double getMax(double extent), String name, double constraint) { + void testIntrinsicsForValues(double Function(double extent) getMin, double Function(double extent) getMax, String name, double constraint) { final double min = testIntrinsic(getMin, 'getMinIntrinsic$name', constraint); final double max = testIntrinsic(getMax, 'getMaxIntrinsic$name', constraint); if (min > max) { diff --git a/packages/flutter/lib/src/rendering/stack.dart b/packages/flutter/lib/src/rendering/stack.dart index 2a3b414074..375dd68eb4 100644 --- a/packages/flutter/lib/src/rendering/stack.dart +++ b/packages/flutter/lib/src/rendering/stack.dart @@ -436,7 +436,7 @@ class RenderStack extends RenderBox } /// Helper function for calculating the intrinsics metrics of a Stack. - static double getIntrinsicDimension(RenderBox? firstChild, double mainChildSizeGetter(RenderBox child)) { + static double getIntrinsicDimension(RenderBox? firstChild, double Function(RenderBox child) mainChildSizeGetter) { double extent = 0.0; RenderBox? child = firstChild; while (child != null) { diff --git a/packages/flutter/lib/src/scheduler/ticker.dart b/packages/flutter/lib/src/scheduler/ticker.dart index e88a5b068b..087be6f52a 100644 --- a/packages/flutter/lib/src/scheduler/ticker.dart +++ b/packages/flutter/lib/src/scheduler/ticker.dart @@ -442,7 +442,7 @@ class TickerFuture implements Future { } @override - Future then(FutureOr onValue(void value), { Function? onError }) { + Future then(FutureOr Function(void value) onValue, { Function? onError }) { return _primaryCompleter.future.then(onValue, onError: onError); } @@ -452,7 +452,7 @@ class TickerFuture implements Future { } @override - Future whenComplete(dynamic action()) { + Future whenComplete(dynamic Function() action) { return _primaryCompleter.future.whenComplete(action); } diff --git a/packages/flutter/lib/src/services/asset_bundle.dart b/packages/flutter/lib/src/services/asset_bundle.dart index a115209029..249f24c726 100644 --- a/packages/flutter/lib/src/services/asset_bundle.dart +++ b/packages/flutter/lib/src/services/asset_bundle.dart @@ -90,7 +90,7 @@ abstract class AssetBundle { /// /// Implementations may cache the result, so a particular key should only be /// used with one parser for the lifetime of the asset bundle. - Future loadStructuredData(String key, Future parser(String value)); + Future loadStructuredData(String key, Future Function(String value) parser); /// If this is a caching asset bundle, and the given key describes a cached /// asset, then evict the asset from the cache so that the next time it is @@ -136,7 +136,7 @@ class NetworkAssetBundle extends AssetBundle { /// The result is not cached. The parser is run each time the resource is /// fetched. @override - Future loadStructuredData(String key, Future parser(String value)) async { + Future loadStructuredData(String key, Future Function(String value) parser) async { assert(key != null); assert(parser != null); return parser(await loadString(key)); @@ -180,7 +180,7 @@ abstract class CachingAssetBundle extends AssetBundle { /// subsequent calls will be a [SynchronousFuture], which resolves its /// callback synchronously. @override - Future loadStructuredData(String key, Future parser(String value)) { + Future loadStructuredData(String key, Future Function(String value) parser) { assert(key != null); assert(parser != null); if (_structuredDataCache.containsKey(key)) diff --git a/packages/flutter/lib/src/services/platform_channel.dart b/packages/flutter/lib/src/services/platform_channel.dart index 8996ae0156..c403f01f4f 100644 --- a/packages/flutter/lib/src/services/platform_channel.dart +++ b/packages/flutter/lib/src/services/platform_channel.dart @@ -429,7 +429,7 @@ class MethodChannel { /// is not set. bool checkMockMethodCallHandler(Future Function(MethodCall call)? handler) => _methodChannelMockHandlers[this] == handler; - Future _handleAsMethodCall(ByteData? message, Future? handler(MethodCall call)) async { + Future _handleAsMethodCall(ByteData? message, Future? Function(MethodCall call) handler) async { final MethodCall call = codec.decodeMethodCall(message); try { return codec.encodeSuccessEnvelope(await handler(call)); diff --git a/packages/flutter/lib/src/services/text_formatter.dart b/packages/flutter/lib/src/services/text_formatter.dart index c10cc3a699..d943dddd1e 100644 --- a/packages/flutter/lib/src/services/text_formatter.dart +++ b/packages/flutter/lib/src/services/text_formatter.dart @@ -530,7 +530,7 @@ class LengthLimitingTextInputFormatter extends TextInputFormatter { TextEditingValue _selectionAwareTextManipulation( TextEditingValue value, - String substringManipulation(String substring), + String Function(String substring) substringManipulation, ) { final int selectionStartIndex = value.selection.start; final int selectionEndIndex = value.selection.end; diff --git a/packages/flutter/lib/src/widgets/actions.dart b/packages/flutter/lib/src/widgets/actions.dart index c49cecb7f4..af7fc636e6 100644 --- a/packages/flutter/lib/src/widgets/actions.dart +++ b/packages/flutter/lib/src/widgets/actions.dart @@ -733,7 +733,7 @@ class Actions extends StatefulWidget { // Visits the Actions widget ancestors of the given element using // getElementForInheritedWidgetOfExactType. Returns true if the visitor found // what it was looking for. - static bool _visitActionsAncestors(BuildContext context, bool visitor(InheritedElement element)) { + static bool _visitActionsAncestors(BuildContext context, bool Function(InheritedElement element) visitor) { InheritedElement? actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsMarker>(); while (actionsElement != null) { if (visitor(actionsElement) == true) { diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index b86c4a3d9b..9254944db0 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -2232,7 +2232,7 @@ abstract class BuildContext { /// because the element tree is no longer stable at that time. To refer to /// an ancestor from one of those methods, save a reference to the ancestor /// by calling [visitAncestorElements] in [State.didChangeDependencies]. - void visitAncestorElements(bool visitor(Element element)); + void visitAncestorElements(bool Function(Element element) visitor); /// Walks the children of this widget. /// @@ -2458,7 +2458,7 @@ class BuildOwner { /// /// This mechanism is used to ensure that, for instance, [State.dispose] does /// not call [State.setState]. - void lockState(void callback()) { + void lockState(VoidCallback callback) { assert(callback != null); assert(_debugStateLockLevel >= 0); assert(() { @@ -4031,7 +4031,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { } @override - void visitAncestorElements(bool visitor(Element element)) { + void visitAncestorElements(bool Function(Element element) visitor) { assert(_debugCheckStateIsActiveForAncestorLookup()); Element? ancestor = _parent; while (ancestor != null && visitor(ancestor)) diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index dffeab6e3c..dbe708cfd6 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -767,7 +767,7 @@ mixin WidgetInspectorService { /// name "ext.flutter.inspector.name"), which takes no arguments. void _registerSignalServiceExtension({ required String name, - required FutureOr callback(), + required FutureOr Function() callback, }) { registerServiceExtension( name: name, @@ -785,7 +785,7 @@ mixin WidgetInspectorService { /// references to avoid leaking memory. void _registerObjectGroupServiceExtension({ required String name, - required FutureOr callback(String objectGroup), + required FutureOr Function(String objectGroup) callback, }) { registerServiceExtension( name: name, @@ -854,7 +854,7 @@ mixin WidgetInspectorService { /// lifetimes of object references in the returned JSON (see [disposeGroup]). void _registerServiceExtensionWithArg({ required String name, - required FutureOr callback(String? objectId, String objectGroup), + required FutureOr Function(String? objectId, String objectGroup) callback, }) { registerServiceExtension( name: name, @@ -872,7 +872,7 @@ mixin WidgetInspectorService { /// "arg0", "arg1", "arg2", ..., "argn". void _registerServiceExtensionVarArgs({ required String name, - required FutureOr callback(List args), + required FutureOr Function(List args) callback, }) { registerServiceExtension( name: name, diff --git a/packages/flutter/test/_goldens_web.dart b/packages/flutter/test/_goldens_web.dart index c36468e1ed..57c0fbad75 100644 --- a/packages/flutter/test/_goldens_web.dart +++ b/packages/flutter/test/_goldens_web.dart @@ -5,4 +5,4 @@ import 'dart:async'; // package:flutter_goldens is not used as part of the test process for web. -Future testExecutable(FutureOr testMain()) async => testMain(); +Future testExecutable(FutureOr Function() testMain) async => testMain(); diff --git a/packages/flutter/test/flutter_test_config.dart b/packages/flutter/test/flutter_test_config.dart index 5cd25242d1..e6c0c9855e 100644 --- a/packages/flutter/test/flutter_test_config.dart +++ b/packages/flutter/test/flutter_test_config.dart @@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; import '_goldens_io.dart' if (dart.library.html) '_goldens_web.dart' as flutter_goldens; -Future testExecutable(FutureOr testMain()) { +Future testExecutable(FutureOr Function() testMain) { // Enable checks because there are many implementations of [RenderBox] in this // package can benefit from the additional validations. debugCheckIntrinsicSizes = true; diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart index fa2c7adfe7..bf393ddd57 100644 --- a/packages/flutter/test/material/date_picker_test.dart +++ b/packages/flutter/test/material/date_picker_test.dart @@ -56,7 +56,7 @@ void main() { Future prepareDatePicker( WidgetTester tester, - Future callback(Future date), + Future Function(Future date) callback, { TextDirection textDirection = TextDirection.ltr } ) async { late BuildContext buttonContext; diff --git a/packages/flutter/test/material/date_range_picker_test.dart b/packages/flutter/test/material/date_range_picker_test.dart index 70480209e4..a464e8e416 100644 --- a/packages/flutter/test/material/date_range_picker_test.dart +++ b/packages/flutter/test/material/date_range_picker_test.dart @@ -52,7 +52,7 @@ void main() { Future preparePicker( WidgetTester tester, - Future callback(Future date), + Future Function(Future date) callback, { TextDirection textDirection = TextDirection.ltr } ) async { late BuildContext buttonContext; diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index ffe288b4c0..099eb544ed 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -560,7 +560,7 @@ void main() { }); group('close button', () { - Future expectCloseIcon(WidgetTester tester, PageRoute routeBuilder(), String type) async { + Future expectCloseIcon(WidgetTester tester, PageRoute Function() routeBuilder, String type) async { const IconData expectedIcon = Icons.close; await tester.pumpWidget( MaterialApp( diff --git a/packages/flutter/test/rendering/layers_test.dart b/packages/flutter/test/rendering/layers_test.dart index 1c974ea1e6..47460f8fc8 100644 --- a/packages/flutter/test/rendering/layers_test.dart +++ b/packages/flutter/test/rendering/layers_test.dart @@ -215,7 +215,7 @@ void main() { ); }); - void checkNeedsAddToScene(Layer layer, void mutateCallback()) { + void checkNeedsAddToScene(Layer layer, void Function() mutateCallback) { layer.debugMarkClean(); layer.updateSubtreeNeedsAddToScene(); expect(layer.debugSubtreeNeedsAddToScene, false); diff --git a/packages/flutter/test/scheduler/scheduler_test.dart b/packages/flutter/test/scheduler/scheduler_test.dart index cc52cbc7d7..fda00aa94a 100644 --- a/packages/flutter/test/scheduler/scheduler_test.dart +++ b/packages/flutter/test/scheduler/scheduler_test.dart @@ -117,7 +117,7 @@ void main() { scheduler.scheduleTask(() { taskExecuted = true; }, Priority.touch); }, zoneSpecification: ZoneSpecification( - createTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()) { + createTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration duration, void Function() f) { // Don't actually run the tasks, just record that it was scheduled. timerQueueTasks.add(f); return DummyTimer(); diff --git a/packages/flutter/test/widgets/widget_inspector_structure_error_test.dart b/packages/flutter/test/widgets/widget_inspector_structure_error_test.dart index c52988a754..229e34962a 100644 --- a/packages/flutter/test/widgets/widget_inspector_structure_error_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_structure_error_test.dart @@ -24,7 +24,7 @@ class StructureErrorTestWidgetInspectorService extends Object with WidgetInspect @override void registerServiceExtension({ required String name, - required FutureOr> callback(Map parameters), + required FutureOr> Function(Map parameters) callback, }) { assert(!extensions.containsKey(name)); extensions[name] = callback; diff --git a/packages/flutter_driver/lib/src/common/handler_factory.dart b/packages/flutter_driver/lib/src/common/handler_factory.dart index c6dadaedf5..f0ba0221e6 100644 --- a/packages/flutter_driver/lib/src/common/handler_factory.dart +++ b/packages/flutter_driver/lib/src/common/handler_factory.dart @@ -478,7 +478,7 @@ mixin CommandHandlerFactory { } // Waits until at the end of a frame the provided [condition] is [true]. - Future _waitUntilFrame(bool condition(), [ Completer? completer ]) { + Future _waitUntilFrame(bool Function() condition, [ Completer? completer ]) { completer ??= Completer(); if (!condition()) { SchedulerBinding.instance!.addPostFrameCallback((Duration timestamp) { diff --git a/packages/flutter_driver/lib/src/driver/driver.dart b/packages/flutter_driver/lib/src/driver/driver.dart index 3fff55e8bd..9b20532cc0 100644 --- a/packages/flutter_driver/lib/src/driver/driver.dart +++ b/packages/flutter_driver/lib/src/driver/driver.dart @@ -656,7 +656,7 @@ abstract class FlutterDriver { /// /// For [WebFlutterDriver], this is only supported for Chrome. Future traceAction( - Future action(), { + Future Function() action, { List streams = const [TimelineStream.all], bool retainPriorEvents = false, }) async { @@ -691,7 +691,7 @@ abstract class FlutterDriver { /// With frame sync disabled, it's the responsibility of the test author to /// ensure that no action is performed while the app is undergoing a /// transition to avoid flakiness. - Future runUnsynchronized(Future action(), { Duration? timeout }) async { + Future runUnsynchronized(Future Function() action, { Duration? timeout }) async { await sendCommand(SetFrameSync(false, timeout: timeout)); T result; try { diff --git a/packages/flutter_driver/lib/src/driver/timeline_summary.dart b/packages/flutter_driver/lib/src/driver/timeline_summary.dart index b1f5d79617..8f01c62e15 100644 --- a/packages/flutter_driver/lib/src/driver/timeline_summary.dart +++ b/packages/flutter_driver/lib/src/driver/timeline_summary.dart @@ -236,7 +236,7 @@ class TimelineSummary { List _extractDurations( String name, - Duration extractor(TimelineEvent beginEvent, TimelineEvent endEvent), + Duration Function(TimelineEvent beginEvent, TimelineEvent endEvent) extractor, ) { final List result = []; final List events = _extractNamedEvents(name); diff --git a/packages/flutter_driver/lib/src/driver/vmservice_driver.dart b/packages/flutter_driver/lib/src/driver/vmservice_driver.dart index 3ad09fa25d..c2f531a861 100644 --- a/packages/flutter_driver/lib/src/driver/vmservice_driver.dart +++ b/packages/flutter_driver/lib/src/driver/vmservice_driver.dart @@ -440,7 +440,7 @@ class VMServiceFlutterDriver extends FlutterDriver { @override Future traceAction( - Future action(), { + Future Function() action, { List streams = const [TimelineStream.all], bool retainPriorEvents = false, }) async { @@ -493,7 +493,7 @@ class VMServiceFlutterDriver extends FlutterDriver { } @override - Future runUnsynchronized(Future action(), { Duration? timeout }) async { + Future runUnsynchronized(Future Function() action, { Duration? timeout }) async { await sendCommand(SetFrameSync(false, timeout: timeout)); T result; try { diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 4b1fed1dd3..32959112e5 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -26,7 +26,7 @@ const String _kFlutterRootKey = 'FLUTTER_ROOT'; /// [goldenFileComparator] to an instance of [FlutterGoldenFileComparator] that /// works for the current test. _Which_ FlutterGoldenFileComparator is /// instantiated is based on the current testing environment. -Future testExecutable(FutureOr testMain()) async { +Future testExecutable(FutureOr Function() testMain) async { const Platform platform = LocalPlatform(); if (FlutterPostSubmitFileComparator.isAvailableForEnvironment(platform)) { goldenFileComparator = await FlutterPostSubmitFileComparator.fromDefaultComparator(platform); diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index a92a9a0e91..85626d51b7 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -35,7 +35,7 @@ const List _kFailPngBytes = 120, 1, 99, 249, 207, 240, 255, 63, 0, 7, 18, 3, 2, 164, 147, 160, 197, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]; -Future testWithOutput(String name, Future body(), String expectedOutput) async { +Future testWithOutput(String name, Future Function() body, String expectedOutput) async { test(name, () async { final StringBuffer output = StringBuffer(); void _recordPrint(Zone self, ZoneDelegate parent, Zone zone, String line) { @@ -780,9 +780,9 @@ class FakeHttpClientResponse extends Fake implements HttpClientResponse { @override StreamSubscription> listen( - void onData(List event)?, { + void Function(List event)? onData, { Function? onError, - void onDone()?, + void Function()? onDone, bool? cancelOnError, }) { return Stream>.fromFuture(Future>.value(response)) @@ -796,7 +796,7 @@ class FakeHttpImageResponse extends Fake implements HttpClientResponse { final List> response; @override - Future forEach(void action(List element)) async { + Future forEach(void Function(List element) action) async { response.forEach(action); } } diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index 270a494597..fca099e3e9 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -402,7 +402,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase /// current timeout, if any. See [AutomatedTestWidgetsFlutterBinding.addTime] /// for details. Future runAsync( - Future callback(), { + Future Function() callback, { Duration additionalTime = const Duration(milliseconds: 1000), }); @@ -600,7 +600,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase /// /// The `timeout` argument sets the initial timeout, if any. It can /// be increased with [addTime]. By default there is no timeout. - Future runTest(Future testBody(), VoidCallback invariantTester, { String description = '', Duration? timeout }); + Future runTest(Future Function() testBody, VoidCallback invariantTester, { String description = '', Duration? timeout }); /// This is called during test execution before and after the body has been /// executed. @@ -641,7 +641,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase } Future _runTest( - Future testBody(), + Future Function() testBody, VoidCallback invariantTester, String description, { Future? timeout, @@ -774,7 +774,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase return testCompleter.future; } - Future _runTestBody(Future testBody(), VoidCallback invariantTester) async { + Future _runTestBody(Future Function() testBody, VoidCallback invariantTester) async { assert(inTest); // So that we can assert that it remains the same after the test finishes. _beforeTestCheckIntrinsicSizes = debugCheckIntrinsicSizes; @@ -979,7 +979,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { @override Future runAsync( - Future callback(), { + Future Function() callback, { Duration additionalTime = const Duration(milliseconds: 1000), }) { assert(additionalTime != null); @@ -996,13 +996,13 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { final Zone realAsyncZone = Zone.current.fork( specification: ZoneSpecification( - scheduleMicrotask: (Zone self, ZoneDelegate parent, Zone zone, void f()) { + scheduleMicrotask: (Zone self, ZoneDelegate parent, Zone zone, void Function() f) { Zone.root.scheduleMicrotask(f); }, - createTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()) { + createTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration duration, void Function() f) { return Zone.root.createTimer(duration, f); }, - createPeriodicTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration period, void f(Timer timer)) { + createPeriodicTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration period, void Function(Timer timer) f) { return Zone.root.createPeriodicTimer(period, f); }, ), @@ -1166,7 +1166,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { @override Future runTest( - Future testBody(), + Future Function() testBody, VoidCallback invariantTester, { String description = '', Duration? timeout, @@ -1582,7 +1582,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { @override Future runAsync( - Future callback(), { + Future Function() callback, { Duration additionalTime = const Duration(milliseconds: 1000), }) async { assert(() { @@ -1615,7 +1615,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { } @override - Future runTest(Future testBody(), VoidCallback invariantTester, { String description = '', Duration? timeout }) async { + Future runTest(Future Function() testBody, VoidCallback invariantTester, { String description = '', Duration? timeout }) async { assert(description != null); assert(!inTest); _inTest = true; diff --git a/packages/flutter_test/lib/src/controller.dart b/packages/flutter_test/lib/src/controller.dart index ba3339a092..52ec8ab9f7 100644 --- a/packages/flutter_test/lib/src/controller.dart +++ b/packages/flutter_test/lib/src/controller.dart @@ -890,7 +890,7 @@ abstract class WidgetController { /// in the documentation for the [flutter_test] library. static bool hitTestWarningShouldBeFatal = false; - Offset _getElementPoint(Finder finder, Offset sizeToPoint(Size size), { required bool warnIfMissed, required String callee }) { + Offset _getElementPoint(Finder finder, Offset Function(Size size) sizeToPoint, { required bool warnIfMissed, required String callee }) { TestAsyncUtils.guardSync(); final Iterable elements = finder.evaluate(); if (elements.isEmpty) { diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 9adf5a4487..43c763af4d 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -685,7 +685,7 @@ class _FindsWidgetMatcher extends Matcher { } } -bool _hasAncestorMatching(Finder finder, bool predicate(Widget widget)) { +bool _hasAncestorMatching(Finder finder, bool Function(Widget widget) predicate) { final Iterable nodes = finder.evaluate(); if (nodes.length != 1) return false; diff --git a/packages/flutter_test/lib/src/test_async_utils.dart b/packages/flutter_test/lib/src/test_async_utils.dart index c06f68d3da..9ac7ba8b8a 100644 --- a/packages/flutter_test/lib/src/test_async_utils.dart +++ b/packages/flutter_test/lib/src/test_async_utils.dart @@ -60,7 +60,7 @@ class TestAsyncUtils { /// this one before this one has finished will throw an exception. /// /// This method first calls [guardSync]. - static Future guard(Future body()) { + static Future guard(Future Function() body) { guardSync(); final Zone zone = Zone.current.fork( zoneValues: { diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index 5193f9cae7..4f8a66fc6c 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -746,7 +746,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker /// * Expose a [Future] in your application code that signals the readiness of /// your widget tree, then await that future inside [callback]. Future runAsync( - Future callback(), { + Future Function() callback, { Duration additionalTime = const Duration(milliseconds: 1000), }) => binding.runAsync(callback, additionalTime: additionalTime); diff --git a/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart b/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart index dd581b6a4a..669486887a 100644 --- a/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart +++ b/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart @@ -7,7 +7,7 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; -Future testExecutable(FutureOr testMain()) async { +Future testExecutable(FutureOr Function() testMain) async { reportTestException = (FlutterErrorDetails details, String testDescription) { expect(details.exception, isA()); expect((details.exception as StateError).message, 'foo'); diff --git a/packages/flutter_test/test/goldens_test.dart b/packages/flutter_test/test/goldens_test.dart index 9502d54057..cf4d2c4ff3 100644 --- a/packages/flutter_test/test/goldens_test.dart +++ b/packages/flutter_test/test/goldens_test.dart @@ -52,7 +52,7 @@ void main() { return path.replaceAll('/', fs.path.separator); } - void test(String description, FutureOr body()) { + void test(String description, FutureOr Function() body) { test_package.test(description, () async { await io.IOOverrides.runZoned>( body, diff --git a/packages/flutter_test/test/test_config/flutter_test_config.dart b/packages/flutter_test/test/test_config/flutter_test_config.dart index a6cae024cb..b95bb88243 100644 --- a/packages/flutter_test/test/test_config/flutter_test_config.dart +++ b/packages/flutter_test/test/test_config/flutter_test_config.dart @@ -4,7 +4,7 @@ import 'dart:async'; -Future testExecutable(FutureOr testMain()) async { +Future testExecutable(FutureOr Function() testMain) async { await runZoned(testMain, zoneValues: { String: '/test_config', }); diff --git a/packages/flutter_test/test/test_config/nested_config/flutter_test_config.dart b/packages/flutter_test/test/test_config/nested_config/flutter_test_config.dart index 1c231f6af7..591e40c119 100644 --- a/packages/flutter_test/test/test_config/nested_config/flutter_test_config.dart +++ b/packages/flutter_test/test/test_config/nested_config/flutter_test_config.dart @@ -4,7 +4,7 @@ import 'dart:async'; -Future testExecutable(FutureOr testMain()) async { +Future testExecutable(FutureOr Function() testMain) async { await runZoned(testMain, zoneValues: { String: '/test_config/nested_config', int: 123, diff --git a/packages/flutter_tools/lib/runner.dart b/packages/flutter_tools/lib/runner.dart index b9c84cf42d..1ece23839c 100644 --- a/packages/flutter_tools/lib/runner.dart +++ b/packages/flutter_tools/lib/runner.dart @@ -94,7 +94,7 @@ Future _handleToolError( bool verbose, List args, bool reportCrashes, - String getFlutterVersion(), + String Function() getFlutterVersion, ) async { if (error is UsageException) { globals.printError('${error.message}\n'); diff --git a/packages/flutter_tools/lib/src/base/context.dart b/packages/flutter_tools/lib/src/base/context.dart index d76cb04755..d2fb46d99f 100644 --- a/packages/flutter_tools/lib/src/base/context.dart +++ b/packages/flutter_tools/lib/src/base/context.dart @@ -136,7 +136,7 @@ class AppContext { /// name. This is useful for debugging purposes and is analogous to naming a /// thread in Java. Future run({ - @required FutureOr body(), + @required FutureOr Function() body, String name, Map overrides, Map fallbacks, diff --git a/packages/flutter_tools/lib/src/base/file_system.dart b/packages/flutter_tools/lib/src/base/file_system.dart index f74e310e21..0fb275b416 100644 --- a/packages/flutter_tools/lib/src/base/file_system.dart +++ b/packages/flutter_tools/lib/src/base/file_system.dart @@ -123,8 +123,8 @@ class FileSystemUtils { void copyDirectory( Directory srcDir, Directory destDir, { - bool shouldCopyFile(File srcFile, File destFile), - void onFileCopied(File srcFile, File destFile), + bool Function(File srcFile, File destFile) shouldCopyFile, + void Function(File srcFile, File destFile) onFileCopied, }) { if (!srcDir.existsSync()) { throw Exception('Source directory "${srcDir.path}" does not exist, nothing to copy'); diff --git a/packages/flutter_tools/lib/src/build_system/build_system.dart b/packages/flutter_tools/lib/src/build_system/build_system.dart index 6abfb88020..a476b8d277 100644 --- a/packages/flutter_tools/lib/src/build_system/build_system.dart +++ b/packages/flutter_tools/lib/src/build_system/build_system.dart @@ -205,7 +205,7 @@ abstract class Target { } /// Performs a fold across this target and its dependencies. - T fold(T initialValue, T combine(T previousValue, Target target)) { + T fold(T initialValue, T Function(T previousValue, Target target) combine) { final T dependencyResult = dependencies.fold( initialValue, (T prev, Target t) => t.fold(prev, combine)); return combine(dependencyResult, this); diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index 0110a8c84d..f3c36d0894 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -1075,7 +1075,7 @@ class AppInstance { _logger.close(); } - Future _runInZone(AppDomain domain, FutureOr method()) async { + Future _runInZone(AppDomain domain, FutureOr Function() method) async { return method(); } } diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index 8ea6cfe939..0471f2cc6c 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -1398,7 +1398,7 @@ class PubDependencyTree { // Produces a 16-bit checksum from the codePoints of the package name and // version strings using Fletcher's algorithm. -String _computeChecksum(Iterable names, String getVersion(String name)) { +String _computeChecksum(Iterable names, String Function(String name) getVersion) { int lowerCheck = 0; int upperCheck = 0; final List sortedNames = names.toList()..sort(); diff --git a/packages/flutter_tools/lib/src/context_runner.dart b/packages/flutter_tools/lib/src/context_runner.dart index d128243bda..4a4b3db73f 100644 --- a/packages/flutter_tools/lib/src/context_runner.dart +++ b/packages/flutter_tools/lib/src/context_runner.dart @@ -62,7 +62,7 @@ import 'windows/visual_studio_validator.dart'; import 'windows/windows_workflow.dart'; Future runInContext( - FutureOr runner(), { + FutureOr Function() runner, { Map overrides, }) async { diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart index 5e51b1b0c1..22f8b0c252 100644 --- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart @@ -650,7 +650,7 @@ class XcodeProjectInfo { return 'Release'; } - static String _uniqueMatch(Iterable strings, bool matches(String s)) { + static String _uniqueMatch(Iterable strings, bool Function(String s) matches) { final List options = strings.where(matches).toList(); if (options.length == 1) { return options.first; diff --git a/packages/flutter_tools/lib/src/reporting/crash_reporting.dart b/packages/flutter_tools/lib/src/reporting/crash_reporting.dart index 1b0f656098..35c57054ba 100644 --- a/packages/flutter_tools/lib/src/reporting/crash_reporting.dart +++ b/packages/flutter_tools/lib/src/reporting/crash_reporting.dart @@ -136,7 +136,7 @@ class CrashReportSender { Future sendReport({ @required dynamic error, @required StackTrace stackTrace, - @required String getFlutterVersion(), + @required String Function() getFlutterVersion, @required String command, }) async { // Only send one crash report per run. diff --git a/packages/flutter_tools/lib/src/test/flutter_tester_device.dart b/packages/flutter_tools/lib/src/test/flutter_tester_device.dart index 7f82618298..c75896e04f 100644 --- a/packages/flutter_tools/lib/src/test/flutter_tester_device.dart +++ b/packages/flutter_tools/lib/src/test/flutter_tester_device.dart @@ -272,7 +272,7 @@ class FlutterTesterTestDevice extends TestDevice { void _pipeStandardStreamsToConsole({ @required Process process, - @required Future reportObservatoryUri(Uri uri), + @required Future Function(Uri uri) reportObservatoryUri, }) { const String observatoryString = 'Observatory listening on '; for (final Stream> stream in >>[ diff --git a/packages/flutter_tools/test/general.shard/android/android_device_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_test.dart index 6d32874118..a35c395c17 100644 --- a/packages/flutter_tools/test/general.shard/android/android_device_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_device_test.dart @@ -652,7 +652,7 @@ class FakeWorkingAndroidConsoleSocket extends Fake implements Socket { final StreamController _controller = StreamController(); @override - Stream asyncMap(FutureOr convert(Uint8List event)) => _controller.stream as Stream; + Stream asyncMap(FutureOr Function(Uint8List event) convert) => _controller.stream as Stream; @override void add(List data) { @@ -676,7 +676,7 @@ class FakeUnresponsiveAndroidConsoleSocket extends Fake implements Socket { final StreamController _controller = StreamController(); @override - Stream asyncMap(FutureOr convert(Uint8List event)) => _controller.stream as Stream; + Stream asyncMap(FutureOr Function(Uint8List event) convert) => _controller.stream as Stream; @override void add(List data) {} @@ -697,7 +697,7 @@ class FakeDisconnectingAndroidConsoleSocket extends Fake implements Socket { final StreamController _controller = StreamController(); @override - Stream asyncMap(FutureOr convert(Uint8List event)) => _controller.stream as Stream; + Stream asyncMap(FutureOr Function(Uint8List event) convert) => _controller.stream as Stream; @override void add(List data) { diff --git a/packages/flutter_tools/test/general.shard/android/gradle_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_test.dart index 65fbe1dd3b..9ea1b5a70b 100644 --- a/packages/flutter_tools/test/general.shard/android/gradle_test.dart +++ b/packages/flutter_tools/test/general.shard/android/gradle_test.dart @@ -325,7 +325,7 @@ include ':app' android = fakePlatform('android'); }); - void testUsingAndroidContext(String description, dynamic testMethod()) { + void testUsingAndroidContext(String description, dynamic Function() testMethod) { testUsingContext(description, testMethod, overrides: { Artifacts: () => localEngineArtifacts, Platform: () => android, diff --git a/packages/flutter_tools/test/general.shard/base/logger_test.dart b/packages/flutter_tools/test/general.shard/base/logger_test.dart index 08315f2d53..78c63fa77d 100644 --- a/packages/flutter_tools/test/general.shard/base/logger_test.dart +++ b/packages/flutter_tools/test/general.shard/base/logger_test.dart @@ -388,7 +388,7 @@ void main() { List outputStdout() => mockStdio.writtenToStdout.join('').split('\n'); List outputStderr() => mockStdio.writtenToStderr.join('').split('\n'); - void doWhileAsync(FakeAsync time, bool doThis()) { + void doWhileAsync(FakeAsync time, bool Function() doThis) { do { mockStopwatch.elapsed += const Duration(milliseconds: 1); time.elapse(const Duration(milliseconds: 1)); diff --git a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart index ea2a90162f..eb71580ed4 100644 --- a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart @@ -649,7 +649,7 @@ Information about project "Runner": fs.file(xcodebuild).createSync(recursive: true); }); - void testUsingOsxContext(String description, dynamic testMethod()) { + void testUsingOsxContext(String description, dynamic Function() testMethod) { testUsingContext(description, testMethod, overrides: { Artifacts: () => localArtifacts, Platform: () => macOS, diff --git a/packages/flutter_tools/test/general.shard/project_test.dart b/packages/flutter_tools/test/general.shard/project_test.dart index 546b1ec3da..11a13d53fb 100644 --- a/packages/flutter_tools/test/general.shard/project_test.dart +++ b/packages/flutter_tools/test/general.shard/project_test.dart @@ -379,7 +379,7 @@ apply plugin: 'kotlin-android' ); }); - void testWithMocks(String description, Future testMethod()) { + void testWithMocks(String description, Future Function() testMethod) { testUsingContext(description, testMethod, overrides: { FileSystem: () => fs, ProcessManager: () => FakeProcessManager.any(), @@ -808,7 +808,7 @@ flutter: /// Executes the [testMethod] in a context where the file system /// is in memory. @isTest -void _testInMemory(String description, Future testMethod()) { +void _testInMemory(String description, Future Function() testMethod) { Cache.flutterRoot = getFlutterRoot(); final FileSystem testFileSystem = MemoryFileSystem( style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, @@ -896,7 +896,7 @@ void expectNotExists(FileSystemEntity entity) { expect(entity.existsSync(), isFalse); } -void addIosProjectFile(Directory directory, {String projectFileContent()}) { +void addIosProjectFile(Directory directory, {String Function() projectFileContent}) { directory .childDirectory('ios') .childDirectory('Runner.xcodeproj') @@ -905,7 +905,7 @@ void addIosProjectFile(Directory directory, {String projectFileContent()}) { ..writeAsStringSync(projectFileContent()); } -void addAndroidGradleFile(Directory directory, { String gradleFileContent() }) { +void addAndroidGradleFile(Directory directory, { String Function() gradleFileContent }) { directory .childDirectory('android') .childDirectory('app') diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index 28fe2fada1..738c7435de 100644 --- a/packages/flutter_tools/test/src/common.dart +++ b/packages/flutter_tools/test/src/common.dart @@ -179,7 +179,7 @@ Matcher containsIgnoringWhitespace(String toSearch) { /// system temporary directory are deleted after each test by calling /// `LocalFileSystem.dispose()`. @isTest -void test(String description, FutureOr body(), { +void test(String description, FutureOr Function() body, { String testOn, Timeout timeout, dynamic skip, @@ -213,7 +213,7 @@ void test(String description, FutureOr body(), { /// /// For more information, see https://github.com/flutter/flutter/issues/47161 @isTest -void testWithoutContext(String description, FutureOr body(), { +void testWithoutContext(String description, FutureOr Function() body, { String testOn, Timeout timeout, dynamic skip, diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index aea9800151..82bf6824f4 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart @@ -56,7 +56,7 @@ typedef ContextInitializer = void Function(AppContext testContext); @isTest void testUsingContext( String description, - dynamic testMethod(), { + dynamic Function() testMethod, { Map overrides = const {}, bool initializeFlutterRoot = true, String testOn, diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart index 51ccce47bf..04153904b1 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart @@ -372,7 +372,7 @@ class FuchsiaRemoteConnection { // will be updated in the event that ports are found to be broken/stale: they // will be shut down and removed from tracking. Future> _invokeForAllVms( - Future vmFunction(DartVm vmService), [ + Future Function(DartVm vmService) vmFunction, [ bool queueEvents = true, ]) async { final List result = []; diff --git a/packages/integration_test/lib/integration_test.dart b/packages/integration_test/lib/integration_test.dart index 3a74de947e..79f8441979 100644 --- a/packages/integration_test/lib/integration_test.dart +++ b/packages/integration_test/lib/integration_test.dart @@ -180,7 +180,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding @override Future runTest( - Future testBody(), + Future Function() testBody, VoidCallback invariantTester, { String description = '', Duration? timeout, @@ -232,7 +232,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding /// [action]. Otherwise, prior events are cleared before calling [action]. By /// default, prior events are cleared. Future traceTimeline( - Future action(), { + Future Function() action, { List streams = const ['all'], bool retainPriorEvents = false, }) async { @@ -268,7 +268,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding /// The `streams` and `retainPriorEvents` parameters are passed as-is to /// [traceTimeline]. Future traceAction( - Future action(), { + Future Function() action, { List streams = const ['all'], bool retainPriorEvents = false, String reportKey = 'timeline', @@ -288,7 +288,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding /// This can be used to implement performance tests previously using /// [traceAction] and [TimelineSummary] from [flutter_driver] Future watchPerformance( - Future action(), { + Future Function() action, { String reportKey = 'performance', }) async { assert(() {