Unverified Commit 7b251f5f authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Enable use_function_type_syntax_for_parameters lint (#77163)

parent 8f9c6af2
...@@ -214,7 +214,7 @@ linter: ...@@ -214,7 +214,7 @@ linter:
- unrelated_type_equality_checks - unrelated_type_equality_checks
# - unsafe_html # not yet tested # - unsafe_html # not yet tested
- use_full_hex_values_for_flutter_colors - 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_if_null_to_convert_nulls_to_bools # not yet tested
- use_is_even_rather_than_modulo - use_is_even_rather_than_modulo
- use_key_in_widget_constructors - use_key_in_widget_constructors
......
...@@ -40,8 +40,8 @@ void macroPerfTest( ...@@ -40,8 +40,8 @@ void macroPerfTest(
{ Duration pageDelay, { Duration pageDelay,
Duration duration = const Duration(seconds: 3), Duration duration = const Duration(seconds: 3),
Duration timeout = kTimeout, Duration timeout = kTimeout,
Future<void> driverOps(FlutterDriver driver), Future<void> Function(FlutterDriver driver) driverOps,
Future<void> setupOps(FlutterDriver driver), Future<void> Function(FlutterDriver driver) setupOps,
}) { }) {
test(testName, () async { test(testName, () async {
Timeline timeline; Timeline timeline;
......
...@@ -115,7 +115,7 @@ class FakeProcessManager extends Mock implements ProcessManager { ...@@ -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. /// A fake process that can be used to interact with a process "started" by the FakeProcessManager.
class FakeProcess extends Mock implements Process { class FakeProcess extends Mock implements Process {
FakeProcess(ProcessResult result, {void stdinResults(String input)}) FakeProcess(ProcessResult result, {void Function(String input) stdinResults})
: stdoutStream = Stream<List<int>>.value((result.stdout as String).codeUnits), : stdoutStream = Stream<List<int>>.value((result.stdout as String).codeUnits),
stderrStream = Stream<List<int>>.value((result.stderr as String).codeUnits), stderrStream = Stream<List<int>>.value((result.stderr as String).codeUnits),
desiredExitCode = result.exitCode, desiredExitCode = result.exitCode,
......
...@@ -30,7 +30,7 @@ final List<String> baseApkFiles = <String> [ ...@@ -30,7 +30,7 @@ final List<String> baseApkFiles = <String> [
]; ];
/// Runs the given [testFunction] on a freshly generated Flutter project. /// Runs the given [testFunction] on a freshly generated Flutter project.
Future<void> runProjectTest(Future<void> testFunction(FlutterProject project)) async { Future<void> runProjectTest(Future<void> Function(FlutterProject project) testFunction) async {
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_plugin_test.'); final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_plugin_test.');
final FlutterProject project = await FlutterProject.create(tempDir, 'hello'); final FlutterProject project = await FlutterProject.create(tempDir, 'hello');
...@@ -42,7 +42,7 @@ Future<void> runProjectTest(Future<void> testFunction(FlutterProject project)) a ...@@ -42,7 +42,7 @@ Future<void> runProjectTest(Future<void> testFunction(FlutterProject project)) a
} }
/// Runs the given [testFunction] on a freshly generated Flutter plugin project. /// Runs the given [testFunction] on a freshly generated Flutter plugin project.
Future<void> runPluginProjectTest(Future<void> testFunction(FlutterPluginProject pluginProject)) async { Future<void> runPluginProjectTest(Future<void> Function(FlutterPluginProject pluginProject) testFunction) async {
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_plugin_test.'); final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_plugin_test.');
final FlutterPluginProject pluginProject = await FlutterPluginProject.create(tempDir, 'aaa'); final FlutterPluginProject pluginProject = await FlutterPluginProject.create(tempDir, 'aaa');
...@@ -54,7 +54,7 @@ Future<void> runPluginProjectTest(Future<void> testFunction(FlutterPluginProject ...@@ -54,7 +54,7 @@ Future<void> runPluginProjectTest(Future<void> testFunction(FlutterPluginProject
} }
/// Runs the given [testFunction] on a freshly generated Flutter module project. /// Runs the given [testFunction] on a freshly generated Flutter module project.
Future<void> runModuleProjectTest(Future<void> testFunction(FlutterModuleProject moduleProject)) async { Future<void> runModuleProjectTest(Future<void> Function(FlutterModuleProject moduleProject) testFunction) async {
final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_module_test.'); final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_gradle_module_test.');
final FlutterModuleProject moduleProject = await FlutterModuleProject.create(tempDir, 'hello_module'); final FlutterModuleProject moduleProject = await FlutterModuleProject.create(tempDir, 'hello_module');
......
...@@ -514,7 +514,7 @@ Future<String> findJavaHome() async { ...@@ -514,7 +514,7 @@ Future<String> findJavaHome() async {
return path.dirname(path.dirname(javaBinary)); return path.dirname(path.dirname(javaBinary));
} }
Future<T> inDirectory<T>(dynamic directory, Future<T> action()) async { Future<T> inDirectory<T>(dynamic directory, Future<T> Function() action) async {
final String previousCwd = cwd; final String previousCwd = cwd;
try { try {
cd(directory); cd(directory);
...@@ -629,7 +629,7 @@ Iterable<String> grep(Pattern pattern, {@required String from}) { ...@@ -629,7 +629,7 @@ Iterable<String> grep(Pattern pattern, {@required String from}) {
/// } catch (error, chain) { /// } catch (error, chain) {
/// ///
/// } /// }
Future<void> runAndCaptureAsyncStacks(Future<void> callback()) { Future<void> runAndCaptureAsyncStacks(Future<void> Function() callback) {
final Completer<void> completer = Completer<void>(); final Completer<void> completer = Completer<void>();
Chain.capture(() async { Chain.capture(() async {
await callback(); await callback();
......
...@@ -78,7 +78,7 @@ class DessertDataSource extends DataTableSource { ...@@ -78,7 +78,7 @@ class DessertDataSource extends DataTableSource {
Dessert('Coconut slice and KitKat', 677, 41.0, 72, 8.5, 63, 12, 12), Dessert('Coconut slice and KitKat', 677, 41.0, 72, 8.5, 63, 12, 12),
]; ];
void _sort<T>(Comparable<T> getField(Dessert d), bool ascending) { void _sort<T>(Comparable<T> Function(Dessert d) getField, bool ascending) {
_desserts.sort((Dessert a, Dessert b) { _desserts.sort((Dessert a, Dessert b) {
if (!ascending) { if (!ascending) {
final Dessert c = a; final Dessert c = a;
...@@ -156,7 +156,7 @@ class _DataTableDemoState extends State<DataTableDemo> { ...@@ -156,7 +156,7 @@ class _DataTableDemoState extends State<DataTableDemo> {
bool _sortAscending = true; bool _sortAscending = true;
final DessertDataSource _dessertsDataSource = DessertDataSource(); final DessertDataSource _dessertsDataSource = DessertDataSource();
void _sort<T>(Comparable<T> getField(Dessert d), int columnIndex, bool ascending) { void _sort<T>(Comparable<T> Function(Dessert d) getField, int columnIndex, bool ascending) {
_dessertsDataSource._sort<T>(getField, ascending); _dessertsDataSource._sort<T>(getField, ascending);
setState(() { setState(() {
_sortColumnIndex = columnIndex; _sortColumnIndex = columnIndex;
......
...@@ -53,7 +53,7 @@ class TestAssetBundle extends AssetBundle { ...@@ -53,7 +53,7 @@ class TestAssetBundle extends AssetBundle {
} }
@override @override
Future<T> loadStructuredData<T>(String key, Future<T> parser(String value)) async { Future<T> loadStructuredData<T>(String key, Future<T> Function(String value) parser) async {
return parser(await loadString(key)); return parser(await loadString(key));
} }
......
...@@ -109,7 +109,7 @@ class _LiveWidgetController extends LiveWidgetController { ...@@ -109,7 +109,7 @@ class _LiveWidgetController extends LiveWidgetController {
bool frameSync = true; bool frameSync = true;
/// Waits until at the end of a frame the provided [condition] is [true]. /// Waits until at the end of a frame the provided [condition] is [true].
Future<void> _waitUntilFrame(bool condition(), [Completer<void>? completer]) { Future<void> _waitUntilFrame(bool Function() condition, [Completer<void>? completer]) {
completer ??= Completer<void>(); completer ??= Completer<void>();
if (!condition()) { if (!condition()) {
SchedulerBinding.instance!.addPostFrameCallback((Duration timestamp) { SchedulerBinding.instance!.addPostFrameCallback((Duration timestamp) {
......
...@@ -182,7 +182,7 @@ class CardCollectionState extends State<CardCollection> { ...@@ -182,7 +182,7 @@ class CardCollectionState extends State<CardCollection> {
}); });
} }
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( return ListTile(
onTap: enabled ? callback : null, onTap: enabled ? callback : null,
title: Text(label), title: Text(label),
......
...@@ -313,7 +313,7 @@ void createSearchMetadata(String templatePath, String metadataPath) { ...@@ -313,7 +313,7 @@ void createSearchMetadata(String templatePath, String metadataPath) {
/// specified, for each source/destination file pair. /// specified, for each source/destination file pair.
/// ///
/// Creates `destDir` if needed. /// 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()) if (!srcDir.existsSync())
throw Exception('Source directory "${srcDir.path}" does not exist, nothing to copy'); throw Exception('Source directory "${srcDir.path}" does not exist, nothing to copy');
......
...@@ -136,17 +136,17 @@ class CachingIterable<E> extends IterableBase<E> { ...@@ -136,17 +136,17 @@ class CachingIterable<E> extends IterableBase<E> {
} }
@override @override
Iterable<T> map<T>(T f(E e)) { Iterable<T> map<T>(T Function(E e) f) {
return CachingIterable<T>(super.map<T>(f).iterator); return CachingIterable<T>(super.map<T>(f).iterator);
} }
@override @override
Iterable<E> where(bool test(E element)) { Iterable<E> where(bool Function(E element) test) {
return CachingIterable<E>(super.where(test).iterator); return CachingIterable<E>(super.where(test).iterator);
} }
@override @override
Iterable<T> expand<T>(Iterable<T> f(E element)) { Iterable<T> expand<T>(Iterable<T> Function(E element) f) {
return CachingIterable<T>(super.expand<T>(f).iterator); return CachingIterable<T>(super.expand<T>(f).iterator);
} }
...@@ -156,7 +156,7 @@ class CachingIterable<E> extends IterableBase<E> { ...@@ -156,7 +156,7 @@ class CachingIterable<E> extends IterableBase<E> {
} }
@override @override
Iterable<E> takeWhile(bool test(E value)) { Iterable<E> takeWhile(bool Function(E value) test) {
return CachingIterable<E>(super.takeWhile(test).iterator); return CachingIterable<E>(super.takeWhile(test).iterator);
} }
...@@ -166,7 +166,7 @@ class CachingIterable<E> extends IterableBase<E> { ...@@ -166,7 +166,7 @@ class CachingIterable<E> extends IterableBase<E> {
} }
@override @override
Iterable<E> skipWhile(bool test(E value)) { Iterable<E> skipWhile(bool Function(E value) test) {
return CachingIterable<E>(super.skipWhile(test).iterator); return CachingIterable<E>(super.skipWhile(test).iterator);
} }
......
...@@ -290,7 +290,7 @@ abstract class BindingBase { ...@@ -290,7 +290,7 @@ abstract class BindingBase {
/// ///
/// The [Future] returned by the `callback` argument is returned by [lockEvents]. /// The [Future] returned by the `callback` argument is returned by [lockEvents].
@protected @protected
Future<void> lockEvents(Future<void> callback()) { Future<void> lockEvents(Future<void> Function() callback) {
developer.Timeline.startSync('Lock events'); developer.Timeline.startSync('Lock events');
assert(callback != null); assert(callback != null);
......
...@@ -51,7 +51,7 @@ bool debugInstrumentationEnabled = false; ...@@ -51,7 +51,7 @@ bool debugInstrumentationEnabled = false;
/// * [Timeline], which is used to record synchronous tracing events for /// * [Timeline], which is used to record synchronous tracing events for
/// visualization in Chrome's tracing format. This method does not /// visualization in Chrome's tracing format. This method does not
/// implicitly add any timeline events. /// implicitly add any timeline events.
Future<T> debugInstrumentAction<T>(String description, Future<T> action()) async { Future<T> debugInstrumentAction<T>(String description, Future<T> Function() action) async {
bool instrument = false; bool instrument = false;
assert(() { assert(() {
instrument = debugInstrumentationEnabled; instrument = debugInstrumentationEnabled;
......
...@@ -34,10 +34,10 @@ class SynchronousFuture<T> implements Future<T> { ...@@ -34,10 +34,10 @@ class SynchronousFuture<T> implements Future<T> {
} }
@override @override
Future<T> catchError(Function onError, { bool test(Object error)? }) => Completer<T>().future; Future<T> catchError(Function onError, { bool Function(Object error)? test }) => Completer<T>().future;
@override @override
Future<R> then<R>(FutureOr<R> onValue(T value), { Function? onError }) { Future<R> then<R>(FutureOr<R> Function(T value) onValue, { Function? onError }) {
final dynamic result = onValue(_value); final dynamic result = onValue(_value);
if (result is Future<R>) if (result is Future<R>)
return result; return result;
...@@ -45,12 +45,12 @@ class SynchronousFuture<T> implements Future<T> { ...@@ -45,12 +45,12 @@ class SynchronousFuture<T> implements Future<T> {
} }
@override @override
Future<T> timeout(Duration timeLimit, { FutureOr<T> onTimeout()? }) { Future<T> timeout(Duration timeLimit, { FutureOr<T> Function()? onTimeout }) {
return Future<T>.value(_value).timeout(timeLimit, onTimeout: onTimeout); return Future<T>.value(_value).timeout(timeLimit, onTimeout: onTimeout);
} }
@override @override
Future<T> whenComplete(FutureOr<dynamic> action()) { Future<T> whenComplete(FutureOr<dynamic> Function() action) {
try { try {
final FutureOr<dynamic> result = action(); final FutureOr<dynamic> result = action();
if (result is Future) if (result is Future)
......
...@@ -1978,7 +1978,7 @@ class _FifoCache<K, V> { ...@@ -1978,7 +1978,7 @@ class _FifoCache<K, V> {
/// if not, calls the given callback to obtain it first. /// if not, calls the given callback to obtain it first.
/// ///
/// The arguments must not be null. /// The arguments must not be null.
V putIfAbsent(K key, V loader()) { V putIfAbsent(K key, V Function() loader) {
assert(key != null); assert(key != null);
assert(loader != null); assert(loader != null);
final V? result = _cache[key]; final V? result = _cache[key];
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
// found in the LICENSE file. // 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]. /// Clip utilities used by [PaintingContext].
abstract class ClipContext { abstract class ClipContext {
/// The canvas on which to paint. /// The canvas on which to paint.
Canvas get canvas; 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); assert(canvasClipCall != null);
canvas.save(); canvas.save();
switch (clipBehavior) { switch (clipBehavior) {
...@@ -38,7 +38,7 @@ abstract class ClipContext { ...@@ -38,7 +38,7 @@ abstract class ClipContext {
/// restored to the pre-clip status afterwards. /// restored to the pre-clip status afterwards.
/// ///
/// `bounds` is the saveLayer bounds used for [Clip.antiAliasWithSaveLayer]. /// `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); _clipAndPaint((bool doAntiAias) => canvas.clipPath(path, doAntiAlias: doAntiAias), clipBehavior, bounds, painter);
} }
...@@ -46,7 +46,7 @@ abstract class ClipContext { ...@@ -46,7 +46,7 @@ abstract class ClipContext {
/// restored to the pre-clip status afterwards. /// restored to the pre-clip status afterwards.
/// ///
/// `bounds` is the saveLayer bounds used for [Clip.antiAliasWithSaveLayer]. /// `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); _clipAndPaint((bool doAntiAias) => canvas.clipRRect(rrect, doAntiAlias: doAntiAias), clipBehavior, bounds, painter);
} }
...@@ -54,7 +54,7 @@ abstract class ClipContext { ...@@ -54,7 +54,7 @@ abstract class ClipContext {
/// restored to the pre-clip status afterwards. /// restored to the pre-clip status afterwards.
/// ///
/// `bounds` is the saveLayer bounds used for [Clip.antiAliasWithSaveLayer]. /// `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); _clipAndPaint((bool doAntiAias) => canvas.clipRect(rect, doAntiAlias: doAntiAias), clipBehavior, bounds, painter);
} }
} }
...@@ -314,7 +314,7 @@ class ImageCache { ...@@ -314,7 +314,7 @@ class ImageCache {
/// `onError` is also provided. When an exception is caught resolving an image, /// `onError` is also provided. When an exception is caught resolving an image,
/// no completers are cached and `null` is returned instead of a new /// no completers are cached and `null` is returned instead of a new
/// completer. /// completer.
ImageStreamCompleter? putIfAbsent(Object key, ImageStreamCompleter loader(), { ImageErrorListener? onError }) { ImageStreamCompleter? putIfAbsent(Object key, ImageStreamCompleter Function() loader, { ImageErrorListener? onError }) {
assert(key != null); assert(key != null);
assert(loader != null); assert(loader != null);
TimelineTask? timelineTask; TimelineTask? timelineTask;
......
...@@ -1360,7 +1360,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1360,7 +1360,7 @@ abstract class RenderBox extends RenderObject {
Map<_IntrinsicDimensionsCacheEntry, double>? _cachedIntrinsicDimensions; 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 assert(RenderObject.debugCheckingIntrinsics || !debugDoingThisResize); // performResize should not depend on anything except the incoming constraints
bool shouldCache = true; bool shouldCache = true;
assert(() { assert(() {
...@@ -2238,7 +2238,7 @@ abstract class RenderBox extends RenderObject { ...@@ -2238,7 +2238,7 @@ abstract class RenderBox extends RenderObject {
RenderObject.debugCheckingIntrinsics = true; RenderObject.debugCheckingIntrinsics = true;
final List<DiagnosticsNode> failures = <DiagnosticsNode>[]; final List<DiagnosticsNode> failures = <DiagnosticsNode>[];
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); final double result = function(constraint);
if (result < 0) { if (result < 0) {
failures.add(ErrorDescription(' * $name($constraint) returned a negative value: $result')); failures.add(ErrorDescription(' * $name($constraint) returned a negative value: $result'));
...@@ -2249,7 +2249,7 @@ abstract class RenderBox extends RenderObject { ...@@ -2249,7 +2249,7 @@ abstract class RenderBox extends RenderObject {
return result; 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 min = testIntrinsic(getMin, 'getMinIntrinsic$name', constraint);
final double max = testIntrinsic(getMax, 'getMaxIntrinsic$name', constraint); final double max = testIntrinsic(getMax, 'getMaxIntrinsic$name', constraint);
if (min > max) { if (min > max) {
......
...@@ -436,7 +436,7 @@ class RenderStack extends RenderBox ...@@ -436,7 +436,7 @@ class RenderStack extends RenderBox
} }
/// Helper function for calculating the intrinsics metrics of a Stack. /// 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; double extent = 0.0;
RenderBox? child = firstChild; RenderBox? child = firstChild;
while (child != null) { while (child != null) {
......
...@@ -442,7 +442,7 @@ class TickerFuture implements Future<void> { ...@@ -442,7 +442,7 @@ class TickerFuture implements Future<void> {
} }
@override @override
Future<R> then<R>(FutureOr<R> onValue(void value), { Function? onError }) { Future<R> then<R>(FutureOr<R> Function(void value) onValue, { Function? onError }) {
return _primaryCompleter.future.then<R>(onValue, onError: onError); return _primaryCompleter.future.then<R>(onValue, onError: onError);
} }
...@@ -452,7 +452,7 @@ class TickerFuture implements Future<void> { ...@@ -452,7 +452,7 @@ class TickerFuture implements Future<void> {
} }
@override @override
Future<void> whenComplete(dynamic action()) { Future<void> whenComplete(dynamic Function() action) {
return _primaryCompleter.future.whenComplete(action); return _primaryCompleter.future.whenComplete(action);
} }
......
...@@ -90,7 +90,7 @@ abstract class AssetBundle { ...@@ -90,7 +90,7 @@ abstract class AssetBundle {
/// ///
/// Implementations may cache the result, so a particular key should only be /// Implementations may cache the result, so a particular key should only be
/// used with one parser for the lifetime of the asset bundle. /// used with one parser for the lifetime of the asset bundle.
Future<T> loadStructuredData<T>(String key, Future<T> parser(String value)); Future<T> loadStructuredData<T>(String key, Future<T> Function(String value) parser);
/// If this is a caching asset bundle, and the given key describes a cached /// 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 /// asset, then evict the asset from the cache so that the next time it is
...@@ -136,7 +136,7 @@ class NetworkAssetBundle extends AssetBundle { ...@@ -136,7 +136,7 @@ class NetworkAssetBundle extends AssetBundle {
/// The result is not cached. The parser is run each time the resource is /// The result is not cached. The parser is run each time the resource is
/// fetched. /// fetched.
@override @override
Future<T> loadStructuredData<T>(String key, Future<T> parser(String value)) async { Future<T> loadStructuredData<T>(String key, Future<T> Function(String value) parser) async {
assert(key != null); assert(key != null);
assert(parser != null); assert(parser != null);
return parser(await loadString(key)); return parser(await loadString(key));
...@@ -180,7 +180,7 @@ abstract class CachingAssetBundle extends AssetBundle { ...@@ -180,7 +180,7 @@ abstract class CachingAssetBundle extends AssetBundle {
/// subsequent calls will be a [SynchronousFuture], which resolves its /// subsequent calls will be a [SynchronousFuture], which resolves its
/// callback synchronously. /// callback synchronously.
@override @override
Future<T> loadStructuredData<T>(String key, Future<T> parser(String value)) { Future<T> loadStructuredData<T>(String key, Future<T> Function(String value) parser) {
assert(key != null); assert(key != null);
assert(parser != null); assert(parser != null);
if (_structuredDataCache.containsKey(key)) if (_structuredDataCache.containsKey(key))
......
...@@ -429,7 +429,7 @@ class MethodChannel { ...@@ -429,7 +429,7 @@ class MethodChannel {
/// is not set. /// is not set.
bool checkMockMethodCallHandler(Future<dynamic> Function(MethodCall call)? handler) => _methodChannelMockHandlers[this] == handler; bool checkMockMethodCallHandler(Future<dynamic> Function(MethodCall call)? handler) => _methodChannelMockHandlers[this] == handler;
Future<ByteData?> _handleAsMethodCall(ByteData? message, Future<dynamic>? handler(MethodCall call)) async { Future<ByteData?> _handleAsMethodCall(ByteData? message, Future<dynamic>? Function(MethodCall call) handler) async {
final MethodCall call = codec.decodeMethodCall(message); final MethodCall call = codec.decodeMethodCall(message);
try { try {
return codec.encodeSuccessEnvelope(await handler(call)); return codec.encodeSuccessEnvelope(await handler(call));
......
...@@ -530,7 +530,7 @@ class LengthLimitingTextInputFormatter extends TextInputFormatter { ...@@ -530,7 +530,7 @@ class LengthLimitingTextInputFormatter extends TextInputFormatter {
TextEditingValue _selectionAwareTextManipulation( TextEditingValue _selectionAwareTextManipulation(
TextEditingValue value, TextEditingValue value,
String substringManipulation(String substring), String Function(String substring) substringManipulation,
) { ) {
final int selectionStartIndex = value.selection.start; final int selectionStartIndex = value.selection.start;
final int selectionEndIndex = value.selection.end; final int selectionEndIndex = value.selection.end;
......
...@@ -733,7 +733,7 @@ class Actions extends StatefulWidget { ...@@ -733,7 +733,7 @@ class Actions extends StatefulWidget {
// Visits the Actions widget ancestors of the given element using // Visits the Actions widget ancestors of the given element using
// getElementForInheritedWidgetOfExactType. Returns true if the visitor found // getElementForInheritedWidgetOfExactType. Returns true if the visitor found
// what it was looking for. // 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>(); InheritedElement? actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsMarker>();
while (actionsElement != null) { while (actionsElement != null) {
if (visitor(actionsElement) == true) { if (visitor(actionsElement) == true) {
......
...@@ -2232,7 +2232,7 @@ abstract class BuildContext { ...@@ -2232,7 +2232,7 @@ abstract class BuildContext {
/// because the element tree is no longer stable at that time. To refer to /// 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 /// an ancestor from one of those methods, save a reference to the ancestor
/// by calling [visitAncestorElements] in [State.didChangeDependencies]. /// 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. /// Walks the children of this widget.
/// ///
...@@ -2458,7 +2458,7 @@ class BuildOwner { ...@@ -2458,7 +2458,7 @@ class BuildOwner {
/// ///
/// This mechanism is used to ensure that, for instance, [State.dispose] does /// This mechanism is used to ensure that, for instance, [State.dispose] does
/// not call [State.setState]. /// not call [State.setState].
void lockState(void callback()) { void lockState(VoidCallback callback) {
assert(callback != null); assert(callback != null);
assert(_debugStateLockLevel >= 0); assert(_debugStateLockLevel >= 0);
assert(() { assert(() {
...@@ -4031,7 +4031,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ...@@ -4031,7 +4031,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
} }
@override @override
void visitAncestorElements(bool visitor(Element element)) { void visitAncestorElements(bool Function(Element element) visitor) {
assert(_debugCheckStateIsActiveForAncestorLookup()); assert(_debugCheckStateIsActiveForAncestorLookup());
Element? ancestor = _parent; Element? ancestor = _parent;
while (ancestor != null && visitor(ancestor)) while (ancestor != null && visitor(ancestor))
......
...@@ -767,7 +767,7 @@ mixin WidgetInspectorService { ...@@ -767,7 +767,7 @@ mixin WidgetInspectorService {
/// name "ext.flutter.inspector.name"), which takes no arguments. /// name "ext.flutter.inspector.name"), which takes no arguments.
void _registerSignalServiceExtension({ void _registerSignalServiceExtension({
required String name, required String name,
required FutureOr<Object?> callback(), required FutureOr<Object?> Function() callback,
}) { }) {
registerServiceExtension( registerServiceExtension(
name: name, name: name,
...@@ -785,7 +785,7 @@ mixin WidgetInspectorService { ...@@ -785,7 +785,7 @@ mixin WidgetInspectorService {
/// references to avoid leaking memory. /// references to avoid leaking memory.
void _registerObjectGroupServiceExtension({ void _registerObjectGroupServiceExtension({
required String name, required String name,
required FutureOr<Object?> callback(String objectGroup), required FutureOr<Object?> Function(String objectGroup) callback,
}) { }) {
registerServiceExtension( registerServiceExtension(
name: name, name: name,
...@@ -854,7 +854,7 @@ mixin WidgetInspectorService { ...@@ -854,7 +854,7 @@ mixin WidgetInspectorService {
/// lifetimes of object references in the returned JSON (see [disposeGroup]). /// lifetimes of object references in the returned JSON (see [disposeGroup]).
void _registerServiceExtensionWithArg({ void _registerServiceExtensionWithArg({
required String name, required String name,
required FutureOr<Object?> callback(String? objectId, String objectGroup), required FutureOr<Object?> Function(String? objectId, String objectGroup) callback,
}) { }) {
registerServiceExtension( registerServiceExtension(
name: name, name: name,
...@@ -872,7 +872,7 @@ mixin WidgetInspectorService { ...@@ -872,7 +872,7 @@ mixin WidgetInspectorService {
/// "arg0", "arg1", "arg2", ..., "argn". /// "arg0", "arg1", "arg2", ..., "argn".
void _registerServiceExtensionVarArgs({ void _registerServiceExtensionVarArgs({
required String name, required String name,
required FutureOr<Object?> callback(List<String> args), required FutureOr<Object?> Function(List<String> args) callback,
}) { }) {
registerServiceExtension( registerServiceExtension(
name: name, name: name,
......
...@@ -5,4 +5,4 @@ ...@@ -5,4 +5,4 @@
import 'dart:async'; import 'dart:async';
// package:flutter_goldens is not used as part of the test process for web. // package:flutter_goldens is not used as part of the test process for web.
Future<void> testExecutable(FutureOr<void> testMain()) async => testMain(); Future<void> testExecutable(FutureOr<void> Function() testMain) async => testMain();
...@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -10,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
import '_goldens_io.dart' import '_goldens_io.dart'
if (dart.library.html) '_goldens_web.dart' as flutter_goldens; if (dart.library.html) '_goldens_web.dart' as flutter_goldens;
Future<void> testExecutable(FutureOr<void> testMain()) { Future<void> testExecutable(FutureOr<void> Function() testMain) {
// Enable checks because there are many implementations of [RenderBox] in this // Enable checks because there are many implementations of [RenderBox] in this
// package can benefit from the additional validations. // package can benefit from the additional validations.
debugCheckIntrinsicSizes = true; debugCheckIntrinsicSizes = true;
......
...@@ -56,7 +56,7 @@ void main() { ...@@ -56,7 +56,7 @@ void main() {
Future<void> prepareDatePicker( Future<void> prepareDatePicker(
WidgetTester tester, WidgetTester tester,
Future<void> callback(Future<DateTime?> date), Future<void> Function(Future<DateTime?> date) callback,
{ TextDirection textDirection = TextDirection.ltr } { TextDirection textDirection = TextDirection.ltr }
) async { ) async {
late BuildContext buttonContext; late BuildContext buttonContext;
......
...@@ -52,7 +52,7 @@ void main() { ...@@ -52,7 +52,7 @@ void main() {
Future<void> preparePicker( Future<void> preparePicker(
WidgetTester tester, WidgetTester tester,
Future<void> callback(Future<DateTimeRange?> date), Future<void> Function(Future<DateTimeRange?> date) callback,
{ TextDirection textDirection = TextDirection.ltr } { TextDirection textDirection = TextDirection.ltr }
) async { ) async {
late BuildContext buttonContext; late BuildContext buttonContext;
......
...@@ -560,7 +560,7 @@ void main() { ...@@ -560,7 +560,7 @@ void main() {
}); });
group('close button', () { group('close button', () {
Future<void> expectCloseIcon(WidgetTester tester, PageRoute<void> routeBuilder(), String type) async { Future<void> expectCloseIcon(WidgetTester tester, PageRoute<void> Function() routeBuilder, String type) async {
const IconData expectedIcon = Icons.close; const IconData expectedIcon = Icons.close;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
......
...@@ -215,7 +215,7 @@ void main() { ...@@ -215,7 +215,7 @@ void main() {
); );
}); });
void checkNeedsAddToScene(Layer layer, void mutateCallback()) { void checkNeedsAddToScene(Layer layer, void Function() mutateCallback) {
layer.debugMarkClean(); layer.debugMarkClean();
layer.updateSubtreeNeedsAddToScene(); layer.updateSubtreeNeedsAddToScene();
expect(layer.debugSubtreeNeedsAddToScene, false); expect(layer.debugSubtreeNeedsAddToScene, false);
......
...@@ -117,7 +117,7 @@ void main() { ...@@ -117,7 +117,7 @@ void main() {
scheduler.scheduleTask(() { taskExecuted = true; }, Priority.touch); scheduler.scheduleTask(() { taskExecuted = true; }, Priority.touch);
}, },
zoneSpecification: ZoneSpecification( 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. // Don't actually run the tasks, just record that it was scheduled.
timerQueueTasks.add(f); timerQueueTasks.add(f);
return DummyTimer(); return DummyTimer();
......
...@@ -24,7 +24,7 @@ class StructureErrorTestWidgetInspectorService extends Object with WidgetInspect ...@@ -24,7 +24,7 @@ class StructureErrorTestWidgetInspectorService extends Object with WidgetInspect
@override @override
void registerServiceExtension({ void registerServiceExtension({
required String name, required String name,
required FutureOr<Map<String, Object?>> callback(Map<String, String> parameters), required FutureOr<Map<String, Object?>> Function(Map<String, String> parameters) callback,
}) { }) {
assert(!extensions.containsKey(name)); assert(!extensions.containsKey(name));
extensions[name] = callback; extensions[name] = callback;
......
...@@ -478,7 +478,7 @@ mixin CommandHandlerFactory { ...@@ -478,7 +478,7 @@ mixin CommandHandlerFactory {
} }
// Waits until at the end of a frame the provided [condition] is [true]. // Waits until at the end of a frame the provided [condition] is [true].
Future<void> _waitUntilFrame(bool condition(), [ Completer<void>? completer ]) { Future<void> _waitUntilFrame(bool Function() condition, [ Completer<void>? completer ]) {
completer ??= Completer<void>(); completer ??= Completer<void>();
if (!condition()) { if (!condition()) {
SchedulerBinding.instance!.addPostFrameCallback((Duration timestamp) { SchedulerBinding.instance!.addPostFrameCallback((Duration timestamp) {
......
...@@ -656,7 +656,7 @@ abstract class FlutterDriver { ...@@ -656,7 +656,7 @@ abstract class FlutterDriver {
/// ///
/// For [WebFlutterDriver], this is only supported for Chrome. /// For [WebFlutterDriver], this is only supported for Chrome.
Future<Timeline> traceAction( Future<Timeline> traceAction(
Future<dynamic> action(), { Future<dynamic> Function() action, {
List<TimelineStream> streams = const <TimelineStream>[TimelineStream.all], List<TimelineStream> streams = const <TimelineStream>[TimelineStream.all],
bool retainPriorEvents = false, bool retainPriorEvents = false,
}) async { }) async {
...@@ -691,7 +691,7 @@ abstract class FlutterDriver { ...@@ -691,7 +691,7 @@ abstract class FlutterDriver {
/// With frame sync disabled, it's the responsibility of the test author to /// 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 /// ensure that no action is performed while the app is undergoing a
/// transition to avoid flakiness. /// transition to avoid flakiness.
Future<T> runUnsynchronized<T>(Future<T> action(), { Duration? timeout }) async { Future<T> runUnsynchronized<T>(Future<T> Function() action, { Duration? timeout }) async {
await sendCommand(SetFrameSync(false, timeout: timeout)); await sendCommand(SetFrameSync(false, timeout: timeout));
T result; T result;
try { try {
......
...@@ -236,7 +236,7 @@ class TimelineSummary { ...@@ -236,7 +236,7 @@ class TimelineSummary {
List<Duration> _extractDurations( List<Duration> _extractDurations(
String name, String name,
Duration extractor(TimelineEvent beginEvent, TimelineEvent endEvent), Duration Function(TimelineEvent beginEvent, TimelineEvent endEvent) extractor,
) { ) {
final List<Duration> result = <Duration>[]; final List<Duration> result = <Duration>[];
final List<TimelineEvent> events = _extractNamedEvents(name); final List<TimelineEvent> events = _extractNamedEvents(name);
......
...@@ -440,7 +440,7 @@ class VMServiceFlutterDriver extends FlutterDriver { ...@@ -440,7 +440,7 @@ class VMServiceFlutterDriver extends FlutterDriver {
@override @override
Future<Timeline> traceAction( Future<Timeline> traceAction(
Future<dynamic> action(), { Future<dynamic> Function() action, {
List<TimelineStream> streams = const <TimelineStream>[TimelineStream.all], List<TimelineStream> streams = const <TimelineStream>[TimelineStream.all],
bool retainPriorEvents = false, bool retainPriorEvents = false,
}) async { }) async {
...@@ -493,7 +493,7 @@ class VMServiceFlutterDriver extends FlutterDriver { ...@@ -493,7 +493,7 @@ class VMServiceFlutterDriver extends FlutterDriver {
} }
@override @override
Future<T> runUnsynchronized<T>(Future<T> action(), { Duration? timeout }) async { Future<T> runUnsynchronized<T>(Future<T> Function() action, { Duration? timeout }) async {
await sendCommand(SetFrameSync(false, timeout: timeout)); await sendCommand(SetFrameSync(false, timeout: timeout));
T result; T result;
try { try {
......
...@@ -26,7 +26,7 @@ const String _kFlutterRootKey = 'FLUTTER_ROOT'; ...@@ -26,7 +26,7 @@ const String _kFlutterRootKey = 'FLUTTER_ROOT';
/// [goldenFileComparator] to an instance of [FlutterGoldenFileComparator] that /// [goldenFileComparator] to an instance of [FlutterGoldenFileComparator] that
/// works for the current test. _Which_ FlutterGoldenFileComparator is /// works for the current test. _Which_ FlutterGoldenFileComparator is
/// instantiated is based on the current testing environment. /// instantiated is based on the current testing environment.
Future<void> testExecutable(FutureOr<void> testMain()) async { Future<void> testExecutable(FutureOr<void> Function() testMain) async {
const Platform platform = LocalPlatform(); const Platform platform = LocalPlatform();
if (FlutterPostSubmitFileComparator.isAvailableForEnvironment(platform)) { if (FlutterPostSubmitFileComparator.isAvailableForEnvironment(platform)) {
goldenFileComparator = await FlutterPostSubmitFileComparator.fromDefaultComparator(platform); goldenFileComparator = await FlutterPostSubmitFileComparator.fromDefaultComparator(platform);
......
...@@ -35,7 +35,7 @@ const List<int> _kFailPngBytes = ...@@ -35,7 +35,7 @@ const List<int> _kFailPngBytes =
120, 1, 99, 249, 207, 240, 255, 63, 0, 7, 18, 3, 2, 164, 147, 160, 197, 0, 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]; 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130];
Future<void> testWithOutput(String name, Future<void> body(), String expectedOutput) async { Future<void> testWithOutput(String name, Future<void> Function() body, String expectedOutput) async {
test(name, () async { test(name, () async {
final StringBuffer output = StringBuffer(); final StringBuffer output = StringBuffer();
void _recordPrint(Zone self, ZoneDelegate parent, Zone zone, String line) { void _recordPrint(Zone self, ZoneDelegate parent, Zone zone, String line) {
...@@ -780,9 +780,9 @@ class FakeHttpClientResponse extends Fake implements HttpClientResponse { ...@@ -780,9 +780,9 @@ class FakeHttpClientResponse extends Fake implements HttpClientResponse {
@override @override
StreamSubscription<List<int>> listen( StreamSubscription<List<int>> listen(
void onData(List<int> event)?, { void Function(List<int> event)? onData, {
Function? onError, Function? onError,
void onDone()?, void Function()? onDone,
bool? cancelOnError, bool? cancelOnError,
}) { }) {
return Stream<List<int>>.fromFuture(Future<List<int>>.value(response)) return Stream<List<int>>.fromFuture(Future<List<int>>.value(response))
...@@ -796,7 +796,7 @@ class FakeHttpImageResponse extends Fake implements HttpClientResponse { ...@@ -796,7 +796,7 @@ class FakeHttpImageResponse extends Fake implements HttpClientResponse {
final List<List<int>> response; final List<List<int>> response;
@override @override
Future<void> forEach(void action(List<int> element)) async { Future<void> forEach(void Function(List<int> element) action) async {
response.forEach(action); response.forEach(action);
} }
} }
...@@ -402,7 +402,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -402,7 +402,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// current timeout, if any. See [AutomatedTestWidgetsFlutterBinding.addTime] /// current timeout, if any. See [AutomatedTestWidgetsFlutterBinding.addTime]
/// for details. /// for details.
Future<T?> runAsync<T>( Future<T?> runAsync<T>(
Future<T> callback(), { Future<T> Function() callback, {
Duration additionalTime = const Duration(milliseconds: 1000), Duration additionalTime = const Duration(milliseconds: 1000),
}); });
...@@ -600,7 +600,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -600,7 +600,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// ///
/// The `timeout` argument sets the initial timeout, if any. It can /// The `timeout` argument sets the initial timeout, if any. It can
/// be increased with [addTime]. By default there is no timeout. /// be increased with [addTime]. By default there is no timeout.
Future<void> runTest(Future<void> testBody(), VoidCallback invariantTester, { String description = '', Duration? timeout }); Future<void> runTest(Future<void> Function() testBody, VoidCallback invariantTester, { String description = '', Duration? timeout });
/// This is called during test execution before and after the body has been /// This is called during test execution before and after the body has been
/// executed. /// executed.
...@@ -641,7 +641,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -641,7 +641,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
} }
Future<void> _runTest( Future<void> _runTest(
Future<void> testBody(), Future<void> Function() testBody,
VoidCallback invariantTester, VoidCallback invariantTester,
String description, { String description, {
Future<void>? timeout, Future<void>? timeout,
...@@ -774,7 +774,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -774,7 +774,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
return testCompleter.future; return testCompleter.future;
} }
Future<void> _runTestBody(Future<void> testBody(), VoidCallback invariantTester) async { Future<void> _runTestBody(Future<void> Function() testBody, VoidCallback invariantTester) async {
assert(inTest); assert(inTest);
// So that we can assert that it remains the same after the test finishes. // So that we can assert that it remains the same after the test finishes.
_beforeTestCheckIntrinsicSizes = debugCheckIntrinsicSizes; _beforeTestCheckIntrinsicSizes = debugCheckIntrinsicSizes;
...@@ -979,7 +979,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -979,7 +979,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
@override @override
Future<T?> runAsync<T>( Future<T?> runAsync<T>(
Future<T> callback(), { Future<T> Function() callback, {
Duration additionalTime = const Duration(milliseconds: 1000), Duration additionalTime = const Duration(milliseconds: 1000),
}) { }) {
assert(additionalTime != null); assert(additionalTime != null);
...@@ -996,13 +996,13 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -996,13 +996,13 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
final Zone realAsyncZone = Zone.current.fork( final Zone realAsyncZone = Zone.current.fork(
specification: ZoneSpecification( 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); 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); 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); return Zone.root.createPeriodicTimer(period, f);
}, },
), ),
...@@ -1166,7 +1166,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1166,7 +1166,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
@override @override
Future<void> runTest( Future<void> runTest(
Future<void> testBody(), Future<void> Function() testBody,
VoidCallback invariantTester, { VoidCallback invariantTester, {
String description = '', String description = '',
Duration? timeout, Duration? timeout,
...@@ -1582,7 +1582,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1582,7 +1582,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
@override @override
Future<T?> runAsync<T>( Future<T?> runAsync<T>(
Future<T> callback(), { Future<T> Function() callback, {
Duration additionalTime = const Duration(milliseconds: 1000), Duration additionalTime = const Duration(milliseconds: 1000),
}) async { }) async {
assert(() { assert(() {
...@@ -1615,7 +1615,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1615,7 +1615,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
} }
@override @override
Future<void> runTest(Future<void> testBody(), VoidCallback invariantTester, { String description = '', Duration? timeout }) async { Future<void> runTest(Future<void> Function() testBody, VoidCallback invariantTester, { String description = '', Duration? timeout }) async {
assert(description != null); assert(description != null);
assert(!inTest); assert(!inTest);
_inTest = true; _inTest = true;
......
...@@ -890,7 +890,7 @@ abstract class WidgetController { ...@@ -890,7 +890,7 @@ abstract class WidgetController {
/// in the documentation for the [flutter_test] library. /// in the documentation for the [flutter_test] library.
static bool hitTestWarningShouldBeFatal = false; 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(); TestAsyncUtils.guardSync();
final Iterable<Element> elements = finder.evaluate(); final Iterable<Element> elements = finder.evaluate();
if (elements.isEmpty) { if (elements.isEmpty) {
......
...@@ -685,7 +685,7 @@ class _FindsWidgetMatcher extends Matcher { ...@@ -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<Element> nodes = finder.evaluate(); final Iterable<Element> nodes = finder.evaluate();
if (nodes.length != 1) if (nodes.length != 1)
return false; return false;
......
...@@ -60,7 +60,7 @@ class TestAsyncUtils { ...@@ -60,7 +60,7 @@ class TestAsyncUtils {
/// this one before this one has finished will throw an exception. /// this one before this one has finished will throw an exception.
/// ///
/// This method first calls [guardSync]. /// This method first calls [guardSync].
static Future<T> guard<T>(Future<T> body()) { static Future<T> guard<T>(Future<T> Function() body) {
guardSync(); guardSync();
final Zone zone = Zone.current.fork( final Zone zone = Zone.current.fork(
zoneValues: <dynamic, dynamic>{ zoneValues: <dynamic, dynamic>{
......
...@@ -746,7 +746,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker ...@@ -746,7 +746,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
/// * Expose a [Future] in your application code that signals the readiness of /// * Expose a [Future] in your application code that signals the readiness of
/// your widget tree, then await that future inside [callback]. /// your widget tree, then await that future inside [callback].
Future<T?> runAsync<T>( Future<T?> runAsync<T>(
Future<T> callback(), { Future<T> Function() callback, {
Duration additionalTime = const Duration(milliseconds: 1000), Duration additionalTime = const Duration(milliseconds: 1000),
}) => binding.runAsync<T?>(callback, additionalTime: additionalTime); }) => binding.runAsync<T?>(callback, additionalTime: additionalTime);
......
...@@ -7,7 +7,7 @@ import 'dart:async'; ...@@ -7,7 +7,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
Future<void> testExecutable(FutureOr<void> testMain()) async { Future<void> testExecutable(FutureOr<void> Function() testMain) async {
reportTestException = (FlutterErrorDetails details, String testDescription) { reportTestException = (FlutterErrorDetails details, String testDescription) {
expect(details.exception, isA<StateError>()); expect(details.exception, isA<StateError>());
expect((details.exception as StateError).message, 'foo'); expect((details.exception as StateError).message, 'foo');
......
...@@ -52,7 +52,7 @@ void main() { ...@@ -52,7 +52,7 @@ void main() {
return path.replaceAll('/', fs.path.separator); return path.replaceAll('/', fs.path.separator);
} }
void test(String description, FutureOr<void> body()) { void test(String description, FutureOr<void> Function() body) {
test_package.test(description, () async { test_package.test(description, () async {
await io.IOOverrides.runZoned<FutureOr<void>>( await io.IOOverrides.runZoned<FutureOr<void>>(
body, body,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import 'dart:async'; import 'dart:async';
Future<void> testExecutable(FutureOr<void> testMain()) async { Future<void> testExecutable(FutureOr<void> Function() testMain) async {
await runZoned<dynamic>(testMain, zoneValues: <Type, String>{ await runZoned<dynamic>(testMain, zoneValues: <Type, String>{
String: '/test_config', String: '/test_config',
}); });
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import 'dart:async'; import 'dart:async';
Future<void> testExecutable(FutureOr<void> testMain()) async { Future<void> testExecutable(FutureOr<void> Function() testMain) async {
await runZoned<dynamic>(testMain, zoneValues: <Type, dynamic>{ await runZoned<dynamic>(testMain, zoneValues: <Type, dynamic>{
String: '/test_config/nested_config', String: '/test_config/nested_config',
int: 123, int: 123,
......
...@@ -94,7 +94,7 @@ Future<int> _handleToolError( ...@@ -94,7 +94,7 @@ Future<int> _handleToolError(
bool verbose, bool verbose,
List<String> args, List<String> args,
bool reportCrashes, bool reportCrashes,
String getFlutterVersion(), String Function() getFlutterVersion,
) async { ) async {
if (error is UsageException) { if (error is UsageException) {
globals.printError('${error.message}\n'); globals.printError('${error.message}\n');
......
...@@ -136,7 +136,7 @@ class AppContext { ...@@ -136,7 +136,7 @@ class AppContext {
/// name. This is useful for debugging purposes and is analogous to naming a /// name. This is useful for debugging purposes and is analogous to naming a
/// thread in Java. /// thread in Java.
Future<V> run<V>({ Future<V> run<V>({
@required FutureOr<V> body(), @required FutureOr<V> Function() body,
String name, String name,
Map<Type, Generator> overrides, Map<Type, Generator> overrides,
Map<Type, Generator> fallbacks, Map<Type, Generator> fallbacks,
......
...@@ -123,8 +123,8 @@ class FileSystemUtils { ...@@ -123,8 +123,8 @@ class FileSystemUtils {
void copyDirectory( void copyDirectory(
Directory srcDir, Directory srcDir,
Directory destDir, { Directory destDir, {
bool shouldCopyFile(File srcFile, File destFile), bool Function(File srcFile, File destFile) shouldCopyFile,
void onFileCopied(File srcFile, File destFile), void Function(File srcFile, File destFile) onFileCopied,
}) { }) {
if (!srcDir.existsSync()) { if (!srcDir.existsSync()) {
throw Exception('Source directory "${srcDir.path}" does not exist, nothing to copy'); throw Exception('Source directory "${srcDir.path}" does not exist, nothing to copy');
......
...@@ -205,7 +205,7 @@ abstract class Target { ...@@ -205,7 +205,7 @@ abstract class Target {
} }
/// Performs a fold across this target and its dependencies. /// Performs a fold across this target and its dependencies.
T fold<T>(T initialValue, T combine(T previousValue, Target target)) { T fold<T>(T initialValue, T Function(T previousValue, Target target) combine) {
final T dependencyResult = dependencies.fold( final T dependencyResult = dependencies.fold(
initialValue, (T prev, Target t) => t.fold(prev, combine)); initialValue, (T prev, Target t) => t.fold(prev, combine));
return combine(dependencyResult, this); return combine(dependencyResult, this);
......
...@@ -1075,7 +1075,7 @@ class AppInstance { ...@@ -1075,7 +1075,7 @@ class AppInstance {
_logger.close(); _logger.close();
} }
Future<T> _runInZone<T>(AppDomain domain, FutureOr<T> method()) async { Future<T> _runInZone<T>(AppDomain domain, FutureOr<T> Function() method) async {
return method(); return method();
} }
} }
......
...@@ -1398,7 +1398,7 @@ class PubDependencyTree { ...@@ -1398,7 +1398,7 @@ class PubDependencyTree {
// Produces a 16-bit checksum from the codePoints of the package name and // Produces a 16-bit checksum from the codePoints of the package name and
// version strings using Fletcher's algorithm. // version strings using Fletcher's algorithm.
String _computeChecksum(Iterable<String> names, String getVersion(String name)) { String _computeChecksum(Iterable<String> names, String Function(String name) getVersion) {
int lowerCheck = 0; int lowerCheck = 0;
int upperCheck = 0; int upperCheck = 0;
final List<String> sortedNames = names.toList()..sort(); final List<String> sortedNames = names.toList()..sort();
......
...@@ -62,7 +62,7 @@ import 'windows/visual_studio_validator.dart'; ...@@ -62,7 +62,7 @@ import 'windows/visual_studio_validator.dart';
import 'windows/windows_workflow.dart'; import 'windows/windows_workflow.dart';
Future<T> runInContext<T>( Future<T> runInContext<T>(
FutureOr<T> runner(), { FutureOr<T> Function() runner, {
Map<Type, Generator> overrides, Map<Type, Generator> overrides,
}) async { }) async {
......
...@@ -650,7 +650,7 @@ class XcodeProjectInfo { ...@@ -650,7 +650,7 @@ class XcodeProjectInfo {
return 'Release'; return 'Release';
} }
static String _uniqueMatch(Iterable<String> strings, bool matches(String s)) { static String _uniqueMatch(Iterable<String> strings, bool Function(String s) matches) {
final List<String> options = strings.where(matches).toList(); final List<String> options = strings.where(matches).toList();
if (options.length == 1) { if (options.length == 1) {
return options.first; return options.first;
......
...@@ -136,7 +136,7 @@ class CrashReportSender { ...@@ -136,7 +136,7 @@ class CrashReportSender {
Future<void> sendReport({ Future<void> sendReport({
@required dynamic error, @required dynamic error,
@required StackTrace stackTrace, @required StackTrace stackTrace,
@required String getFlutterVersion(), @required String Function() getFlutterVersion,
@required String command, @required String command,
}) async { }) async {
// Only send one crash report per run. // Only send one crash report per run.
......
...@@ -272,7 +272,7 @@ class FlutterTesterTestDevice extends TestDevice { ...@@ -272,7 +272,7 @@ class FlutterTesterTestDevice extends TestDevice {
void _pipeStandardStreamsToConsole({ void _pipeStandardStreamsToConsole({
@required Process process, @required Process process,
@required Future<void> reportObservatoryUri(Uri uri), @required Future<void> Function(Uri uri) reportObservatoryUri,
}) { }) {
const String observatoryString = 'Observatory listening on '; const String observatoryString = 'Observatory listening on ';
for (final Stream<List<int>> stream in <Stream<List<int>>>[ for (final Stream<List<int>> stream in <Stream<List<int>>>[
......
...@@ -652,7 +652,7 @@ class FakeWorkingAndroidConsoleSocket extends Fake implements Socket { ...@@ -652,7 +652,7 @@ class FakeWorkingAndroidConsoleSocket extends Fake implements Socket {
final StreamController<String> _controller = StreamController<String>(); final StreamController<String> _controller = StreamController<String>();
@override @override
Stream<E> asyncMap<E>(FutureOr<E> convert(Uint8List event)) => _controller.stream as Stream<E>; Stream<E> asyncMap<E>(FutureOr<E> Function(Uint8List event) convert) => _controller.stream as Stream<E>;
@override @override
void add(List<int> data) { void add(List<int> data) {
...@@ -676,7 +676,7 @@ class FakeUnresponsiveAndroidConsoleSocket extends Fake implements Socket { ...@@ -676,7 +676,7 @@ class FakeUnresponsiveAndroidConsoleSocket extends Fake implements Socket {
final StreamController<String> _controller = StreamController<String>(); final StreamController<String> _controller = StreamController<String>();
@override @override
Stream<E> asyncMap<E>(FutureOr<E> convert(Uint8List event)) => _controller.stream as Stream<E>; Stream<E> asyncMap<E>(FutureOr<E> Function(Uint8List event) convert) => _controller.stream as Stream<E>;
@override @override
void add(List<int> data) {} void add(List<int> data) {}
...@@ -697,7 +697,7 @@ class FakeDisconnectingAndroidConsoleSocket extends Fake implements Socket { ...@@ -697,7 +697,7 @@ class FakeDisconnectingAndroidConsoleSocket extends Fake implements Socket {
final StreamController<String> _controller = StreamController<String>(); final StreamController<String> _controller = StreamController<String>();
@override @override
Stream<E> asyncMap<E>(FutureOr<E> convert(Uint8List event)) => _controller.stream as Stream<E>; Stream<E> asyncMap<E>(FutureOr<E> Function(Uint8List event) convert) => _controller.stream as Stream<E>;
@override @override
void add(List<int> data) { void add(List<int> data) {
......
...@@ -325,7 +325,7 @@ include ':app' ...@@ -325,7 +325,7 @@ include ':app'
android = fakePlatform('android'); android = fakePlatform('android');
}); });
void testUsingAndroidContext(String description, dynamic testMethod()) { void testUsingAndroidContext(String description, dynamic Function() testMethod) {
testUsingContext(description, testMethod, overrides: <Type, Generator>{ testUsingContext(description, testMethod, overrides: <Type, Generator>{
Artifacts: () => localEngineArtifacts, Artifacts: () => localEngineArtifacts,
Platform: () => android, Platform: () => android,
......
...@@ -388,7 +388,7 @@ void main() { ...@@ -388,7 +388,7 @@ void main() {
List<String> outputStdout() => mockStdio.writtenToStdout.join('').split('\n'); List<String> outputStdout() => mockStdio.writtenToStdout.join('').split('\n');
List<String> outputStderr() => mockStdio.writtenToStderr.join('').split('\n'); List<String> outputStderr() => mockStdio.writtenToStderr.join('').split('\n');
void doWhileAsync(FakeAsync time, bool doThis()) { void doWhileAsync(FakeAsync time, bool Function() doThis) {
do { do {
mockStopwatch.elapsed += const Duration(milliseconds: 1); mockStopwatch.elapsed += const Duration(milliseconds: 1);
time.elapse(const Duration(milliseconds: 1)); time.elapse(const Duration(milliseconds: 1));
......
...@@ -649,7 +649,7 @@ Information about project "Runner": ...@@ -649,7 +649,7 @@ Information about project "Runner":
fs.file(xcodebuild).createSync(recursive: true); fs.file(xcodebuild).createSync(recursive: true);
}); });
void testUsingOsxContext(String description, dynamic testMethod()) { void testUsingOsxContext(String description, dynamic Function() testMethod) {
testUsingContext(description, testMethod, overrides: <Type, Generator>{ testUsingContext(description, testMethod, overrides: <Type, Generator>{
Artifacts: () => localArtifacts, Artifacts: () => localArtifacts,
Platform: () => macOS, Platform: () => macOS,
......
...@@ -379,7 +379,7 @@ apply plugin: 'kotlin-android' ...@@ -379,7 +379,7 @@ apply plugin: 'kotlin-android'
); );
}); });
void testWithMocks(String description, Future<void> testMethod()) { void testWithMocks(String description, Future<void> Function() testMethod) {
testUsingContext(description, testMethod, overrides: <Type, Generator>{ testUsingContext(description, testMethod, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
...@@ -808,7 +808,7 @@ flutter: ...@@ -808,7 +808,7 @@ flutter:
/// Executes the [testMethod] in a context where the file system /// Executes the [testMethod] in a context where the file system
/// is in memory. /// is in memory.
@isTest @isTest
void _testInMemory(String description, Future<void> testMethod()) { void _testInMemory(String description, Future<void> Function() testMethod) {
Cache.flutterRoot = getFlutterRoot(); Cache.flutterRoot = getFlutterRoot();
final FileSystem testFileSystem = MemoryFileSystem( final FileSystem testFileSystem = MemoryFileSystem(
style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix,
...@@ -896,7 +896,7 @@ void expectNotExists(FileSystemEntity entity) { ...@@ -896,7 +896,7 @@ void expectNotExists(FileSystemEntity entity) {
expect(entity.existsSync(), isFalse); expect(entity.existsSync(), isFalse);
} }
void addIosProjectFile(Directory directory, {String projectFileContent()}) { void addIosProjectFile(Directory directory, {String Function() projectFileContent}) {
directory directory
.childDirectory('ios') .childDirectory('ios')
.childDirectory('Runner.xcodeproj') .childDirectory('Runner.xcodeproj')
...@@ -905,7 +905,7 @@ void addIosProjectFile(Directory directory, {String projectFileContent()}) { ...@@ -905,7 +905,7 @@ void addIosProjectFile(Directory directory, {String projectFileContent()}) {
..writeAsStringSync(projectFileContent()); ..writeAsStringSync(projectFileContent());
} }
void addAndroidGradleFile(Directory directory, { String gradleFileContent() }) { void addAndroidGradleFile(Directory directory, { String Function() gradleFileContent }) {
directory directory
.childDirectory('android') .childDirectory('android')
.childDirectory('app') .childDirectory('app')
......
...@@ -179,7 +179,7 @@ Matcher containsIgnoringWhitespace(String toSearch) { ...@@ -179,7 +179,7 @@ Matcher containsIgnoringWhitespace(String toSearch) {
/// system temporary directory are deleted after each test by calling /// system temporary directory are deleted after each test by calling
/// `LocalFileSystem.dispose()`. /// `LocalFileSystem.dispose()`.
@isTest @isTest
void test(String description, FutureOr<void> body(), { void test(String description, FutureOr<void> Function() body, {
String testOn, String testOn,
Timeout timeout, Timeout timeout,
dynamic skip, dynamic skip,
...@@ -213,7 +213,7 @@ void test(String description, FutureOr<void> body(), { ...@@ -213,7 +213,7 @@ void test(String description, FutureOr<void> body(), {
/// ///
/// For more information, see https://github.com/flutter/flutter/issues/47161 /// For more information, see https://github.com/flutter/flutter/issues/47161
@isTest @isTest
void testWithoutContext(String description, FutureOr<void> body(), { void testWithoutContext(String description, FutureOr<void> Function() body, {
String testOn, String testOn,
Timeout timeout, Timeout timeout,
dynamic skip, dynamic skip,
......
...@@ -56,7 +56,7 @@ typedef ContextInitializer = void Function(AppContext testContext); ...@@ -56,7 +56,7 @@ typedef ContextInitializer = void Function(AppContext testContext);
@isTest @isTest
void testUsingContext( void testUsingContext(
String description, String description,
dynamic testMethod(), { dynamic Function() testMethod, {
Map<Type, Generator> overrides = const <Type, Generator>{}, Map<Type, Generator> overrides = const <Type, Generator>{},
bool initializeFlutterRoot = true, bool initializeFlutterRoot = true,
String testOn, String testOn,
......
...@@ -372,7 +372,7 @@ class FuchsiaRemoteConnection { ...@@ -372,7 +372,7 @@ class FuchsiaRemoteConnection {
// will be updated in the event that ports are found to be broken/stale: they // will be updated in the event that ports are found to be broken/stale: they
// will be shut down and removed from tracking. // will be shut down and removed from tracking.
Future<List<E>> _invokeForAllVms<E>( Future<List<E>> _invokeForAllVms<E>(
Future<E> vmFunction(DartVm vmService), [ Future<E> Function(DartVm vmService) vmFunction, [
bool queueEvents = true, bool queueEvents = true,
]) async { ]) async {
final List<E> result = <E>[]; final List<E> result = <E>[];
......
...@@ -180,7 +180,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding ...@@ -180,7 +180,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding
@override @override
Future<void> runTest( Future<void> runTest(
Future<void> testBody(), Future<void> Function() testBody,
VoidCallback invariantTester, { VoidCallback invariantTester, {
String description = '', String description = '',
Duration? timeout, Duration? timeout,
...@@ -232,7 +232,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding ...@@ -232,7 +232,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding
/// [action]. Otherwise, prior events are cleared before calling [action]. By /// [action]. Otherwise, prior events are cleared before calling [action]. By
/// default, prior events are cleared. /// default, prior events are cleared.
Future<vm.Timeline> traceTimeline( Future<vm.Timeline> traceTimeline(
Future<dynamic> action(), { Future<dynamic> Function() action, {
List<String> streams = const <String>['all'], List<String> streams = const <String>['all'],
bool retainPriorEvents = false, bool retainPriorEvents = false,
}) async { }) async {
...@@ -268,7 +268,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding ...@@ -268,7 +268,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding
/// The `streams` and `retainPriorEvents` parameters are passed as-is to /// The `streams` and `retainPriorEvents` parameters are passed as-is to
/// [traceTimeline]. /// [traceTimeline].
Future<void> traceAction( Future<void> traceAction(
Future<dynamic> action(), { Future<dynamic> Function() action, {
List<String> streams = const <String>['all'], List<String> streams = const <String>['all'],
bool retainPriorEvents = false, bool retainPriorEvents = false,
String reportKey = 'timeline', String reportKey = 'timeline',
...@@ -288,7 +288,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding ...@@ -288,7 +288,7 @@ class IntegrationTestWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding
/// This can be used to implement performance tests previously using /// This can be used to implement performance tests previously using
/// [traceAction] and [TimelineSummary] from [flutter_driver] /// [traceAction] and [TimelineSummary] from [flutter_driver]
Future<void> watchPerformance( Future<void> watchPerformance(
Future<void> action(), { Future<void> Function() action, {
String reportKey = 'performance', String reportKey = 'performance',
}) async { }) async {
assert(() { assert(() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment