diff --git a/analysis_options.yaml b/analysis_options.yaml index 19c137ca2a..5f00205026 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -128,7 +128,7 @@ linter: - prefer_final_locals - prefer_foreach # - prefer_function_declarations_over_variables # not yet tested - # - prefer_generic_function_type_aliases # not yet tested + - prefer_generic_function_type_aliases - prefer_initializing_formals # - prefer_interpolation_to_compose_strings # not yet tested - prefer_is_empty diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index e9e8a7617f..ec41f2c855 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -11,7 +11,7 @@ import 'package:meta/meta.dart'; import 'run_command.dart'; -typedef Future ShardRunner(); +typedef ShardRunner = Future Function(); final String flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script)))); final String flutter = path.join(flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter'); diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart index 64f8ed6357..69267631a6 100644 --- a/dev/bots/prepare_package.dart +++ b/dev/bots/prepare_package.dart @@ -175,7 +175,7 @@ class ProcessRunner { } } -typedef Future HttpReader(Uri url, {Map headers}); +typedef HttpReader = Future Function(Uri url, {Map headers}); /// Creates a pre-populated Flutter archive from a git repo. class ArchiveCreator { diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 983f796677..32e083ae47 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -9,7 +9,7 @@ import 'package:path/path.dart' as path; import 'run_command.dart'; -typedef Future ShardRunner(); +typedef ShardRunner = Future Function(); final String flutterRoot = path.dirname(path.dirname(path.dirname(path.fromUri(Platform.script)))); final String flutter = path.join(flutterRoot, 'bin', Platform.isWindows ? 'flutter.bat' : 'flutter'); diff --git a/dev/bots/test/fake_process_manager.dart b/dev/bots/test/fake_process_manager.dart index 719cf6eed1..779d7a5186 100644 --- a/dev/bots/test/fake_process_manager.dart +++ b/dev/bots/test/fake_process_manager.dart @@ -151,7 +151,7 @@ class FakeProcess extends Mock implements Process { } /// Callback used to receive stdin input when it occurs. -typedef void StringReceivedCallback(String received); +typedef StringReceivedCallback = void Function(String received); /// A stream consumer class that consumes UTF8 strings as lists of ints. class StringStreamConsumer implements StreamConsumer> { diff --git a/dev/devicelab/lib/framework/framework.dart b/dev/devicelab/lib/framework/framework.dart index 5bf7edb66c..f3583f0b3e 100644 --- a/dev/devicelab/lib/framework/framework.dart +++ b/dev/devicelab/lib/framework/framework.dart @@ -20,7 +20,7 @@ const Duration _kDefaultTaskTimeout = Duration(minutes: 15); /// Represents a unit of work performed in the CI environment that can /// succeed, fail and be retried independently of others. -typedef Future TaskFunction(); +typedef TaskFunction = Future Function(); bool _isTaskRegistered = false; diff --git a/dev/devicelab/test/adb_test.dart b/dev/devicelab/test/adb_test.dart index 525746fdfa..17c0736a0e 100644 --- a/dev/devicelab/test/adb_test.dart +++ b/dev/devicelab/test/adb_test.dart @@ -122,7 +122,7 @@ CommandArgs cmd({ ); } -typedef dynamic ExitErrorFactory(); +typedef ExitErrorFactory = dynamic Function(); class CommandArgs { CommandArgs({ this.command, this.arguments, this.environment }); diff --git a/dev/integration_tests/channels/lib/src/test_step.dart b/dev/integration_tests/channels/lib/src/test_step.dart index 04394f2f7c..39caab24b8 100644 --- a/dev/integration_tests/channels/lib/src/test_step.dart +++ b/dev/integration_tests/channels/lib/src/test_step.dart @@ -11,7 +11,7 @@ import 'pair.dart'; enum TestStatus { ok, pending, failed, complete } -typedef Future TestStep(); +typedef TestStep = Future Function(); const String nothing = '-'; diff --git a/dev/integration_tests/platform_interaction/lib/src/test_step.dart b/dev/integration_tests/platform_interaction/lib/src/test_step.dart index 7313e578b8..1da476624d 100644 --- a/dev/integration_tests/platform_interaction/lib/src/test_step.dart +++ b/dev/integration_tests/platform_interaction/lib/src/test_step.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; enum TestStatus { ok, pending, failed, complete } -typedef Future TestStep(); +typedef TestStep = Future Function(); const String nothing = '-'; diff --git a/dev/manual_tests/lib/material_arc.dart b/dev/manual_tests/lib/material_arc.dart index e4afb81b24..06cdf9f45a 100644 --- a/dev/manual_tests/lib/material_arc.dart +++ b/dev/manual_tests/lib/material_arc.dart @@ -396,7 +396,7 @@ class _RectangleDemoState extends State<_RectangleDemo> { } } -typedef Widget _DemoBuilder(_ArcDemo demo); +typedef _DemoBuilder = Widget Function(_ArcDemo demo); class _ArcDemo { _ArcDemo(this.title, this.builder, TickerProvider vsync) diff --git a/dev/manual_tests/lib/overlay_geometry.dart b/dev/manual_tests/lib/overlay_geometry.dart index e73cb75925..3f1cb370b5 100644 --- a/dev/manual_tests/lib/overlay_geometry.dart +++ b/dev/manual_tests/lib/overlay_geometry.dart @@ -92,7 +92,7 @@ class OverlayGeometryApp extends StatefulWidget { OverlayGeometryAppState createState() => OverlayGeometryAppState(); } -typedef void CardTapCallback(GlobalKey targetKey, Offset globalPosition); +typedef CardTapCallback = void Function(GlobalKey targetKey, Offset globalPosition); class CardBuilder extends SliverChildDelegate { CardBuilder({ this.cardModels, this.onTapUp }); diff --git a/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart b/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart index 15ec62fc06..6fd07e1283 100644 --- a/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart @@ -10,8 +10,8 @@ enum _Location { Bermuda } -typedef Widget DemoItemBodyBuilder(DemoItem item); -typedef String ValueToString(T value); +typedef DemoItemBodyBuilder = Widget Function(DemoItem item); +typedef ValueToString = String Function(T value); class DualHeaderWithHint extends StatelessWidget { const DualHeaderWithHint({ diff --git a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart index 418e045d39..6bf4594773 100644 --- a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart @@ -10,7 +10,7 @@ enum GridDemoTileStyle { twoLine } -typedef void BannerTapCallback(Photo photo); +typedef BannerTapCallback = void Function(Photo photo); const double _kMinFlingVelocity = 800.0; const String _kGalleryAssetsPackage = 'flutter_gallery_assets'; diff --git a/examples/flutter_gallery/lib/gallery/updater.dart b/examples/flutter_gallery/lib/gallery/updater.dart index 6eac7cd9f3..2c8e8f8ed4 100644 --- a/examples/flutter_gallery/lib/gallery/updater.dart +++ b/examples/flutter_gallery/lib/gallery/updater.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; -typedef Future UpdateUrlFetcher(); +typedef UpdateUrlFetcher = Future Function(); class Updater extends StatefulWidget { const Updater({ @required this.updateUrlFetcher, this.child, Key key }) diff --git a/examples/layers/services/isolate.dart b/examples/layers/services/isolate.dart index 0536aeedde..6feeda9256 100644 --- a/examples/layers/services/isolate.dart +++ b/examples/layers/services/isolate.dart @@ -9,8 +9,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -typedef void OnProgressListener(double completed, double total); -typedef void OnResultListener(String result); +typedef OnProgressListener = void Function(double completed, double total); +typedef OnResultListener = void Function(String result); // An encapsulation of a large amount of synchronous processing. // diff --git a/examples/layers/widgets/styled_text.dart b/examples/layers/widgets/styled_text.dart index 0694aa2859..b3dae6ca8f 100644 --- a/examples/layers/widgets/styled_text.dart +++ b/examples/layers/widgets/styled_text.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; -typedef Widget _TextTransformer(String name, String text); +typedef _TextTransformer = Widget Function(String name, String text); // From https://en.wikiquote.org/wiki/2001:_A_Space_Odyssey_(film) const String _kDialogText = ''' diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 2f3e71c560..323850d71c 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -11,7 +11,7 @@ import 'stock_strings.dart'; import 'stock_symbol_viewer.dart'; import 'stock_types.dart'; -typedef void ModeUpdater(StockMode mode); +typedef ModeUpdater = void Function(StockMode mode); enum _StockMenuItem { autorefresh, refresh, speedUp, speedDown } enum StockHomeTab { market, portfolio } diff --git a/examples/stocks/lib/stock_row.dart b/examples/stocks/lib/stock_row.dart index 00e8843f40..3ced34ac31 100644 --- a/examples/stocks/lib/stock_row.dart +++ b/examples/stocks/lib/stock_row.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; import 'stock_arrow.dart'; import 'stock_data.dart'; -typedef void StockRowActionCallback(Stock stock); +typedef StockRowActionCallback = void Function(Stock stock); class StockRow extends StatelessWidget { StockRow({ diff --git a/packages/flutter/lib/src/animation/animation.dart b/packages/flutter/lib/src/animation/animation.dart index 346657356b..be2c9f6d63 100644 --- a/packages/flutter/lib/src/animation/animation.dart +++ b/packages/flutter/lib/src/animation/animation.dart @@ -22,7 +22,7 @@ enum AnimationStatus { } /// Signature for listeners attached using [Animation.addStatusListener]. -typedef void AnimationStatusListener(AnimationStatus status); +typedef AnimationStatusListener = void Function(AnimationStatus status); /// An animation with a value of type `T`. /// diff --git a/packages/flutter/lib/src/cupertino/refresh.dart b/packages/flutter/lib/src/cupertino/refresh.dart index 6f53e3a100..fd64f06476 100644 --- a/packages/flutter/lib/src/cupertino/refresh.dart +++ b/packages/flutter/lib/src/cupertino/refresh.dart @@ -209,7 +209,7 @@ enum RefreshIndicatorMode { /// /// The `pulledExtent` parameter is the currently available space either from /// overscrolling or as held by the sliver during refresh. -typedef Widget RefreshControlIndicatorBuilder( +typedef RefreshControlIndicatorBuilder = Widget Function( BuildContext context, RefreshIndicatorMode refreshState, double pulledExtent, @@ -221,7 +221,7 @@ typedef Widget RefreshControlIndicatorBuilder( /// pulled a `refreshTriggerPullDistance`. Must return a [Future]. Upon /// completion of the [Future], the [CupertinoSliverRefreshControl] enters the /// [RefreshIndicatorMode.done] state and will start to go away. -typedef Future RefreshCallback(); +typedef RefreshCallback = Future Function(); /// A sliver widget implementing the iOS-style pull to refresh content control. /// diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index 1a25579b55..24b459856b 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -441,7 +441,7 @@ class _SegmentedControlContainerBoxParentData extends ContainerBoxParentData extends RenderBox with ContainerRenderObjectMixin>, diff --git a/packages/flutter/lib/src/foundation/assertions.dart b/packages/flutter/lib/src/foundation/assertions.dart index ec92613e97..47330f938e 100644 --- a/packages/flutter/lib/src/foundation/assertions.dart +++ b/packages/flutter/lib/src/foundation/assertions.dart @@ -6,11 +6,11 @@ import 'basic_types.dart'; import 'print.dart'; /// Signature for [FlutterError.onError] handler. -typedef void FlutterExceptionHandler(FlutterErrorDetails details); +typedef FlutterExceptionHandler = void Function(FlutterErrorDetails details); /// Signature for [FlutterErrorDetails.informationCollector] callback /// and other callbacks that collect information into a string buffer. -typedef void InformationCollector(StringBuffer information); +typedef InformationCollector = void Function(StringBuffer information); /// Class for information provided to [FlutterExceptionHandler] callbacks. /// diff --git a/packages/flutter/lib/src/foundation/basic_types.dart b/packages/flutter/lib/src/foundation/basic_types.dart index 9837907230..dcc4faea40 100644 --- a/packages/flutter/lib/src/foundation/basic_types.dart +++ b/packages/flutter/lib/src/foundation/basic_types.dart @@ -12,7 +12,7 @@ export 'dart:ui' show VoidCallback; /// Signature for callbacks that report that an underlying value has changed. /// /// See also [ValueSetter]. -typedef void ValueChanged(T value); +typedef ValueChanged = void Function(T value); /// Signature for callbacks that report that a value has been set. /// @@ -26,7 +26,7 @@ typedef void ValueChanged(T value); /// /// * [ValueGetter], the getter equivalent of this signature. /// * [AsyncValueSetter], an asynchronous version of this signature. -typedef void ValueSetter(T value); +typedef ValueSetter = void Function(T value); /// Signature for callbacks that are to report a value on demand. /// @@ -34,10 +34,10 @@ typedef void ValueSetter(T value); /// /// * [ValueSetter], the setter equivalent of this signature. /// * [AsyncValueGetter], an asynchronous version of this signature. -typedef T ValueGetter(); +typedef ValueGetter = T Function(); /// Signature for callbacks that filter an iterable. -typedef Iterable IterableFilter(Iterable input); +typedef IterableFilter = Iterable Function(Iterable input); /// Signature of callbacks that have no arguments and return no data, but that /// return a [Future] to indicate when their work is complete. @@ -47,7 +47,7 @@ typedef Iterable IterableFilter(Iterable input); /// * [VoidCallback], a synchronous version of this signature. /// * [AsyncValueGetter], a signature for asynchronous getters. /// * [AsyncValueSetter], a signature for asynchronous setters. -typedef Future AsyncCallback(); +typedef AsyncCallback = Future Function(); /// Signature for callbacks that report that a value has been set and return a /// [Future] that completes when the value has been saved. @@ -56,7 +56,7 @@ typedef Future AsyncCallback(); /// /// * [ValueSetter], a synchronous version of this signature. /// * [AsyncValueGetter], the getter equivalent of this signature. -typedef Future AsyncValueSetter(T value); +typedef AsyncValueSetter = Future Function(T value); /// Signature for callbacks that are to asynchronously report a value on demand. /// @@ -64,7 +64,7 @@ typedef Future AsyncValueSetter(T value); /// /// * [ValueGetter], a synchronous version of this signature. /// * [AsyncValueSetter], the setter equivalent of this signature. -typedef Future AsyncValueGetter(); +typedef AsyncValueGetter = Future Function(); // BITFIELD diff --git a/packages/flutter/lib/src/foundation/binding.dart b/packages/flutter/lib/src/foundation/binding.dart index 03b194f8ef..34e4f4269d 100644 --- a/packages/flutter/lib/src/foundation/binding.dart +++ b/packages/flutter/lib/src/foundation/binding.dart @@ -22,7 +22,7 @@ import 'print.dart'; /// "type" key will be set to the string `_extensionType` to indicate /// that this is a return value from a service extension, and the /// "method" key will be set to the full name of the method. -typedef Future> ServiceExtensionCallback(Map parameters); +typedef ServiceExtensionCallback = Future> Function(Map parameters); /// Base class for mixins that provide singleton services (also known as /// "bindings"). diff --git a/packages/flutter/lib/src/foundation/diagnostics.dart b/packages/flutter/lib/src/foundation/diagnostics.dart index ee12ad0968..4f90f82c21 100644 --- a/packages/flutter/lib/src/foundation/diagnostics.dart +++ b/packages/flutter/lib/src/foundation/diagnostics.dart @@ -1661,7 +1661,7 @@ class ObjectFlagProperty extends DiagnosticsProperty { /// May throw exception if accessing the property would throw an exception /// and callers must handle that case gracefully. For example, accessing a /// property may trigger an assert that layout constraints were violated. -typedef T ComputePropertyValueCallback(); +typedef ComputePropertyValueCallback = T Function(); /// Property with a [value] of type [T]. /// diff --git a/packages/flutter/lib/src/foundation/isolates.dart b/packages/flutter/lib/src/foundation/isolates.dart index 6eec08039a..603e05239e 100644 --- a/packages/flutter/lib/src/foundation/isolates.dart +++ b/packages/flutter/lib/src/foundation/isolates.dart @@ -18,7 +18,7 @@ import 'profile.dart'; /// of classes, not closures or instance methods of objects. /// /// {@macro flutter.foundation.compute.limitations} -typedef R ComputeCallback(Q message); +typedef ComputeCallback = R Function(Q message); /// Spawn an isolate, run `callback` on that isolate, passing it `message`, and /// (eventually) return the value returned by `callback`. diff --git a/packages/flutter/lib/src/foundation/licenses.dart b/packages/flutter/lib/src/foundation/licenses.dart index 48544a1c9a..c49c5ccbf0 100644 --- a/packages/flutter/lib/src/foundation/licenses.dart +++ b/packages/flutter/lib/src/foundation/licenses.dart @@ -5,7 +5,7 @@ import 'dart:async'; /// Signature for callbacks passed to [LicenseRegistry.addLicense]. -typedef Stream LicenseEntryCollector(); +typedef LicenseEntryCollector = Stream Function(); /// A string that represents one paragraph in a [LicenseEntry]. /// diff --git a/packages/flutter/lib/src/foundation/print.dart b/packages/flutter/lib/src/foundation/print.dart index c60d3cb4ab..2e8acd114f 100644 --- a/packages/flutter/lib/src/foundation/print.dart +++ b/packages/flutter/lib/src/foundation/print.dart @@ -6,7 +6,7 @@ import 'dart:async'; import 'dart:collection'; /// Signature for [debugPrint] implementations. -typedef void DebugPrintCallback(String message, { int wrapWidth }); +typedef DebugPrintCallback = void Function(String message, { int wrapWidth }); /// Prints a message to the console, which you can access using the "flutter" /// tool's "logs" command ("flutter logs"). diff --git a/packages/flutter/lib/src/gestures/drag_details.dart b/packages/flutter/lib/src/gestures/drag_details.dart index 0a623da80f..eebf316f42 100644 --- a/packages/flutter/lib/src/gestures/drag_details.dart +++ b/packages/flutter/lib/src/gestures/drag_details.dart @@ -38,7 +38,7 @@ class DragDownDetails { /// The `details` object provides the position of the touch. /// /// See [DragGestureRecognizer.onDown]. -typedef void GestureDragDownCallback(DragDownDetails details); +typedef GestureDragDownCallback = void Function(DragDownDetails details); /// Details object for callbacks that use [GestureDragStartCallback]. /// @@ -80,7 +80,7 @@ class DragStartDetails { /// touched the surface. /// /// See [DragGestureRecognizer.onStart]. -typedef void GestureDragStartCallback(DragStartDetails details); +typedef GestureDragStartCallback = void Function(DragStartDetails details); /// Details object for callbacks that use [GestureDragUpdateCallback]. /// @@ -150,7 +150,7 @@ class DragUpdateDetails { /// has travelled since the last update. /// /// See [DragGestureRecognizer.onUpdate]. -typedef void GestureDragUpdateCallback(DragUpdateDetails details); +typedef GestureDragUpdateCallback = void Function(DragUpdateDetails details); /// Details object for callbacks that use [GestureDragEndCallback]. /// diff --git a/packages/flutter/lib/src/gestures/long_press.dart b/packages/flutter/lib/src/gestures/long_press.dart index b0ad86f40b..20c47643b2 100644 --- a/packages/flutter/lib/src/gestures/long_press.dart +++ b/packages/flutter/lib/src/gestures/long_press.dart @@ -9,7 +9,7 @@ import 'recognizer.dart'; /// Signature for when a pointer has remained in contact with the screen at the /// same location for a long period of time. -typedef void GestureLongPressCallback(); +typedef GestureLongPressCallback = void Function(); /// Recognizes when the user has pressed down at the same location for a long /// period of time. diff --git a/packages/flutter/lib/src/gestures/monodrag.dart b/packages/flutter/lib/src/gestures/monodrag.dart index cb8e698911..4c25e6857a 100644 --- a/packages/flutter/lib/src/gestures/monodrag.dart +++ b/packages/flutter/lib/src/gestures/monodrag.dart @@ -22,13 +22,13 @@ enum _DragState { /// the screen is available in the `details`. /// /// See [DragGestureRecognizer.onEnd]. -typedef void GestureDragEndCallback(DragEndDetails details); +typedef GestureDragEndCallback = void Function(DragEndDetails details); /// Signature for when the pointer that previously triggered a /// [GestureDragDownCallback] did not complete. /// /// See [DragGestureRecognizer.onCancel]. -typedef void GestureDragCancelCallback(); +typedef GestureDragCancelCallback = void Function(); /// Recognizes movement. /// diff --git a/packages/flutter/lib/src/gestures/multidrag.dart b/packages/flutter/lib/src/gestures/multidrag.dart index 82cbb981f3..1b115f6566 100644 --- a/packages/flutter/lib/src/gestures/multidrag.dart +++ b/packages/flutter/lib/src/gestures/multidrag.dart @@ -17,7 +17,7 @@ import 'recognizer.dart'; import 'velocity_tracker.dart'; /// Signature for when [MultiDragGestureRecognizer] recognizes the start of a drag gesture. -typedef Drag GestureMultiDragStartCallback(Offset position); +typedef GestureMultiDragStartCallback = Drag Function(Offset position); /// Per-pointer state for a [MultiDragGestureRecognizer]. /// diff --git a/packages/flutter/lib/src/gestures/multitap.dart b/packages/flutter/lib/src/gestures/multitap.dart index fc6d81d91a..ab34379b95 100644 --- a/packages/flutter/lib/src/gestures/multitap.dart +++ b/packages/flutter/lib/src/gestures/multitap.dart @@ -15,22 +15,22 @@ import 'tap.dart'; /// Signature for callback when the user has tapped the screen at the same /// location twice in quick succession. -typedef void GestureDoubleTapCallback(); +typedef GestureDoubleTapCallback = void Function(); /// Signature used by [MultiTapGestureRecognizer] for when a pointer that might /// cause a tap has contacted the screen at a particular location. -typedef void GestureMultiTapDownCallback(int pointer, TapDownDetails details); +typedef GestureMultiTapDownCallback = void Function(int pointer, TapDownDetails details); /// Signature used by [MultiTapGestureRecognizer] for when a pointer that will /// trigger a tap has stopped contacting the screen at a particular location. -typedef void GestureMultiTapUpCallback(int pointer, TapUpDetails details); +typedef GestureMultiTapUpCallback = void Function(int pointer, TapUpDetails details); /// Signature used by [MultiTapGestureRecognizer] for when a tap has occurred. -typedef void GestureMultiTapCallback(int pointer); +typedef GestureMultiTapCallback = void Function(int pointer); /// Signature for when the pointer that previously triggered a /// [GestureMultiTapDownCallback] will not end up causing a tap. -typedef void GestureMultiTapCancelCallback(int pointer); +typedef GestureMultiTapCancelCallback = void Function(int pointer); /// TapTracker helps track individual tap sequences as part of a /// larger gesture. diff --git a/packages/flutter/lib/src/gestures/pointer_router.dart b/packages/flutter/lib/src/gestures/pointer_router.dart index 0ac00cbd56..fc252d755d 100644 --- a/packages/flutter/lib/src/gestures/pointer_router.dart +++ b/packages/flutter/lib/src/gestures/pointer_router.dart @@ -9,7 +9,7 @@ import 'package:flutter/foundation.dart'; import 'events.dart'; /// A callback that receives a [PointerEvent] -typedef void PointerRoute(PointerEvent event); +typedef PointerRoute = void Function(PointerEvent event); /// A routing table for [PointerEvent] events. class PointerRouter { diff --git a/packages/flutter/lib/src/gestures/recognizer.dart b/packages/flutter/lib/src/gestures/recognizer.dart index d35f4612d5..ca71a26b72 100644 --- a/packages/flutter/lib/src/gestures/recognizer.dart +++ b/packages/flutter/lib/src/gestures/recognizer.dart @@ -22,7 +22,7 @@ export 'pointer_router.dart' show PointerRouter; /// [GestureRecognizer.invokeCallback]. This allows the /// [GestureRecognizer.invokeCallback] mechanism to be generically used with /// anonymous functions that return objects of particular types. -typedef T RecognizerCallback(); +typedef RecognizerCallback = T Function(); /// The base class that all gesture recognizers inherit from. /// diff --git a/packages/flutter/lib/src/gestures/scale.dart b/packages/flutter/lib/src/gestures/scale.dart index c594caadd0..d6727497f8 100644 --- a/packages/flutter/lib/src/gestures/scale.dart +++ b/packages/flutter/lib/src/gestures/scale.dart @@ -84,14 +84,14 @@ class ScaleEndDetails { /// Signature for when the pointers in contact with the screen have established /// a focal point and initial scale of 1.0. -typedef void GestureScaleStartCallback(ScaleStartDetails details); +typedef GestureScaleStartCallback = void Function(ScaleStartDetails details); /// Signature for when the pointers in contact with the screen have indicated a /// new focal point and/or scale. -typedef void GestureScaleUpdateCallback(ScaleUpdateDetails details); +typedef GestureScaleUpdateCallback = void Function(ScaleUpdateDetails details); /// Signature for when the pointers are no longer in contact with the screen. -typedef void GestureScaleEndCallback(ScaleEndDetails details); +typedef GestureScaleEndCallback = void Function(ScaleEndDetails details); bool _isFlingGesture(Velocity velocity) { assert(velocity != null); diff --git a/packages/flutter/lib/src/gestures/tap.dart b/packages/flutter/lib/src/gestures/tap.dart index af588ad817..0f063bf8b0 100644 --- a/packages/flutter/lib/src/gestures/tap.dart +++ b/packages/flutter/lib/src/gestures/tap.dart @@ -36,7 +36,7 @@ class TapDownDetails { /// /// * [GestureDetector.onTapDown], which matches this signature. /// * [TapGestureRecognizer], which uses this signature in one of its callbacks. -typedef void GestureTapDownCallback(TapDownDetails details); +typedef GestureTapDownCallback = void Function(TapDownDetails details); /// Details for [GestureTapUpCallback], such as position. /// @@ -65,7 +65,7 @@ class TapUpDetails { /// /// * [GestureDetector.onTapUp], which matches this signature. /// * [TapGestureRecognizer], which uses this signature in one of its callbacks. -typedef void GestureTapUpCallback(TapUpDetails details); +typedef GestureTapUpCallback = void Function(TapUpDetails details); /// Signature for when a tap has occurred. /// @@ -73,7 +73,7 @@ typedef void GestureTapUpCallback(TapUpDetails details); /// /// * [GestureDetector.onTap], which matches this signature. /// * [TapGestureRecognizer], which uses this signature in one of its callbacks. -typedef void GestureTapCallback(); +typedef GestureTapCallback = void Function(); /// Signature for when the pointer that previously triggered a /// [GestureTapDownCallback] will not end up causing a tap. @@ -82,7 +82,7 @@ typedef void GestureTapCallback(); /// /// * [GestureDetector.onTapCancel], which matches this signature. /// * [TapGestureRecognizer], which uses this signature in one of its callbacks. -typedef void GestureTapCancelCallback(); +typedef GestureTapCancelCallback = void Function(); /// Recognizes taps. /// diff --git a/packages/flutter/lib/src/material/animated_icons/animated_icons.dart b/packages/flutter/lib/src/material/animated_icons/animated_icons.dart index b063c2004d..1077544c32 100644 --- a/packages/flutter/lib/src/material/animated_icons/animated_icons.dart +++ b/packages/flutter/lib/src/material/animated_icons/animated_icons.dart @@ -126,7 +126,7 @@ class AnimatedIcon extends StatelessWidget { } } -typedef ui.Path _UiPathFactory(); +typedef _UiPathFactory = ui.Path Function(); class _AnimatedIconPainter extends CustomPainter { _AnimatedIconPainter({ @@ -297,4 +297,4 @@ T _interpolate(List values, double progress, _Interpolator interpolator return interpolator(values[lowIdx], values[highIdx], t); } -typedef T _Interpolator(T a, T b, double progress); +typedef _Interpolator = T Function(T a, T b, double progress); diff --git a/packages/flutter/lib/src/material/arc.dart b/packages/flutter/lib/src/material/arc.dart index be0345cb84..edaf96f986 100644 --- a/packages/flutter/lib/src/material/arc.dart +++ b/packages/flutter/lib/src/material/arc.dart @@ -193,7 +193,7 @@ const List<_Diagonal> _allDiagonals = <_Diagonal>[ _Diagonal(_CornerId.bottomLeft, _CornerId.topRight), ]; -typedef dynamic _KeyFunc(T input); +typedef _KeyFunc = dynamic Function(T input); // Select the element for which the key function returns the maximum value. T _maxBy(Iterable input, _KeyFunc keyFunc) { diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 67e508a647..f76be29abb 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -21,7 +21,7 @@ import 'theme_data.dart'; import 'tooltip.dart'; /// Signature for [DataColumn.onSort] callback. -typedef void DataColumnSortCallback(int columnIndex, bool ascending); +typedef DataColumnSortCallback = void Function(int columnIndex, bool ascending); /// Column configuration for a [DataTable]. /// diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index 55f4a3f748..f6c1e7b685 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -1040,7 +1040,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { /// Signature for predicating dates for enabled date selections. /// /// See [showDatePicker]. -typedef bool SelectableDayPredicate(DateTime day); +typedef SelectableDayPredicate = bool Function(DateTime day); /// Shows a dialog containing a material design date picker. /// diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index 96fac6743c..e5a848c720 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -145,7 +145,7 @@ class Drawer extends StatelessWidget { /// Signature for the callback that's called when a [DrawerController] is /// opened or closed. -typedef void DrawerCallback(bool isOpened); +typedef DrawerCallback = void Function(bool isOpened); /// Provides interactive behavior for [Drawer] widgets. /// diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index 3ed9ccb343..01eabb6dec 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -43,11 +43,11 @@ class _SaltedKey extends LocalKey { /// /// The position of the panel within an [ExpansionPanelList] is given by /// [panelIndex]. -typedef void ExpansionPanelCallback(int panelIndex, bool isExpanded); +typedef ExpansionPanelCallback = void Function(int panelIndex, bool isExpanded); /// Signature for the callback that's called when the header of the /// [ExpansionPanel] needs to rebuild. -typedef Widget ExpansionPanelHeaderBuilder(BuildContext context, bool isExpanded); +typedef ExpansionPanelHeaderBuilder = Widget Function(BuildContext context, bool isExpanded); /// A material expansion panel. It has a header and a body and can be either /// expanded or collapsed. The body of the panel is only visible when it is diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index 88e24d6fed..d522a070b1 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -12,7 +12,7 @@ import 'theme.dart'; /// Signature for the callback used by ink effects to obtain the rectangle for the effect. /// /// Used by [InkHighlight] and [InkSplash], for example. -typedef Rect RectCallback(); +typedef RectCallback = Rect Function(); /// The various kinds of material in material design. Used to /// configure the default behavior of [Material] widgets. diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index d769657f5e..83808d1ebc 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -741,19 +741,19 @@ Future showMenu({ /// dismissed. /// /// Used by [PopupMenuButton.onSelected]. -typedef void PopupMenuItemSelected(T value); +typedef PopupMenuItemSelected = void Function(T value); /// Signature for the callback invoked when a [PopupMenuButton] is dismissed /// without selecting an item. /// /// Used by [PopupMenuButton.onCanceled]. -typedef void PopupMenuCanceled(); +typedef PopupMenuCanceled = void Function(); /// Signature used by [PopupMenuButton] to lazily construct the items shown when /// the button is pressed. /// /// Used by [PopupMenuButton.itemBuilder]. -typedef List> PopupMenuItemBuilder(BuildContext context); +typedef PopupMenuItemBuilder = List> Function(BuildContext context); /// Displays a menu when pressed and calls [onSelected] when the menu is dismissed /// because an item was selected. The value passed to [onSelected] is the value of diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index 1481c6b866..da410e90dc 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart @@ -32,7 +32,7 @@ const Duration _kIndicatorScaleDuration = Duration(milliseconds: 200); /// finished. /// /// Used by [RefreshIndicator.onRefresh]. -typedef Future RefreshCallback(); +typedef RefreshCallback = Future Function(); // The state machine moves through these modes only when the scrollable // identified by scrollableKey has been scrolled to its min or max limit. diff --git a/packages/flutter/lib/src/material/reorderable_list.dart b/packages/flutter/lib/src/material/reorderable_list.dart index 9cd7612035..e5a255366b 100644 --- a/packages/flutter/lib/src/material/reorderable_list.dart +++ b/packages/flutter/lib/src/material/reorderable_list.dart @@ -36,7 +36,7 @@ import 'material_localizations.dart'; /// backingList.insert(newIndex, element); /// } /// ``` -typedef void OnReorderCallback(int oldIndex, int newIndex); +typedef OnReorderCallback = void Function(int oldIndex, int newIndex); /// A list whose items the user can interactively reorder by dragging. /// diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index 78a396b1bc..6890f538b0 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -26,7 +26,7 @@ import 'theme.dart'; /// See also: /// /// * [Slider.semanticFormatterCallback], which shows an example use case. -typedef String SemanticFormatterCallback(double value); +typedef SemanticFormatterCallback = String Function(double value); /// A Material Design slider. /// diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index 55728d0427..a24503eeaf 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -174,7 +174,7 @@ class _TabStyle extends AnimatedWidget { } } -typedef void _LayoutCallback(List xOffsets, TextDirection textDirection, double width); +typedef _LayoutCallback = void Function(List xOffsets, TextDirection textDirection, double width); class _TabLabelBarRenderer extends RenderFlex { _TabLabelBarRenderer({ diff --git a/packages/flutter/lib/src/painting/image_stream.dart b/packages/flutter/lib/src/painting/image_stream.dart index beef3b0e82..57dd522756 100644 --- a/packages/flutter/lib/src/painting/image_stream.dart +++ b/packages/flutter/lib/src/painting/image_stream.dart @@ -66,12 +66,12 @@ class ImageInfo { /// frame is requested if the call was asynchronous (after the current frame) /// and no rendering frame is requested if the call was synchronous (within the /// same stack frame as the call to [ImageStream.addListener]). -typedef void ImageListener(ImageInfo image, bool synchronousCall); +typedef ImageListener = void Function(ImageInfo image, bool synchronousCall); /// Signature for reporting errors when resolving images. /// /// Used by [ImageStream] and [precacheImage] to report errors. -typedef void ImageErrorListener(dynamic exception, StackTrace stackTrace); +typedef ImageErrorListener = void Function(dynamic exception, StackTrace stackTrace); class _ImageListenerPair { _ImageListenerPair(this.listener, this.errorListener); diff --git a/packages/flutter/lib/src/rendering/custom_paint.dart b/packages/flutter/lib/src/rendering/custom_paint.dart index 17e82cfbed..78d04dfe1d 100644 --- a/packages/flutter/lib/src/rendering/custom_paint.dart +++ b/packages/flutter/lib/src/rendering/custom_paint.dart @@ -22,7 +22,7 @@ import 'proxy_box.dart'; /// The returned list must not be mutated after this function completes. To /// change the semantic information, the function must return a new list /// instead. -typedef List SemanticsBuilderCallback(Size size); +typedef SemanticsBuilderCallback = List Function(Size size); /// The interface used by [CustomPaint] (in the widgets library) and /// [RenderCustomPaint] (in the rendering library). diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index db62b5ca24..7c3d8410e4 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -23,7 +23,7 @@ const double _kCaretHeightOffset = 2.0; // pixels /// (including the cursor location). /// /// Used by [RenderEditable.onSelectionChanged]. -typedef void SelectionChangedHandler(TextSelection selection, RenderEditable renderObject, SelectionChangedCause cause); +typedef SelectionChangedHandler = void Function(TextSelection selection, RenderEditable renderObject, SelectionChangedCause cause); /// Indicates what triggered the change in selected text (including changes to /// the cursor location). @@ -47,7 +47,7 @@ enum SelectionChangedCause { /// Signature for the callback that reports when the caret location changes. /// /// Used by [RenderEditable.onCaretChanged]. -typedef void CaretChangedHandler(Rect caretRect); +typedef CaretChangedHandler = void Function(Rect caretRect); /// Represents the coordinates of the point in a selection, and the text /// direction at that point, relative to top left of the [RenderEditable] that diff --git a/packages/flutter/lib/src/rendering/flex.dart b/packages/flutter/lib/src/rendering/flex.dart index 970297467b..5a28531ab9 100644 --- a/packages/flutter/lib/src/rendering/flex.dart +++ b/packages/flutter/lib/src/rendering/flex.dart @@ -212,7 +212,7 @@ bool _startIsTopLeft(Axis direction, TextDirection textDirection, VerticalDirect return null; } -typedef double _ChildSizingFunction(RenderBox child, double extent); +typedef _ChildSizingFunction = double Function(RenderBox child, double extent); /// Displays its children in a one-dimensional array. /// diff --git a/packages/flutter/lib/src/rendering/list_body.dart b/packages/flutter/lib/src/rendering/list_body.dart index 2127d65568..b3149dfef4 100644 --- a/packages/flutter/lib/src/rendering/list_body.dart +++ b/packages/flutter/lib/src/rendering/list_body.dart @@ -10,7 +10,7 @@ import 'object.dart'; /// Parent data for use with [RenderListBody]. class ListBodyParentData extends ContainerBoxParentData { } -typedef double _ChildSizingFunction(RenderBox child); +typedef _ChildSizingFunction = double Function(RenderBox child); /// Displays its children sequentially along a given axis, forcing them to the /// dimensions of the parent in the other axis. diff --git a/packages/flutter/lib/src/rendering/list_wheel_viewport.dart b/packages/flutter/lib/src/rendering/list_wheel_viewport.dart index c9b6903eb8..66f3631dc3 100644 --- a/packages/flutter/lib/src/rendering/list_wheel_viewport.dart +++ b/packages/flutter/lib/src/rendering/list_wheel_viewport.dart @@ -13,7 +13,7 @@ import 'object.dart'; import 'viewport.dart'; import 'viewport_offset.dart'; -typedef double _ChildSizingFunction(RenderBox child); +typedef _ChildSizingFunction = double Function(RenderBox child); /// A delegate used by [RenderListWheelViewport] to manage its children. /// diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index 744004b016..9de50e90be 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -42,7 +42,7 @@ class ParentData { /// of the [PaintingContext.canvas] to the coordinate system of the callee. /// /// Used by many of the methods of [PaintingContext]. -typedef void PaintingContextCallback(PaintingContext context, Offset offset); +typedef PaintingContextCallback = void Function(PaintingContext context, Offset offset); /// A place to paint. /// @@ -586,12 +586,12 @@ abstract class Constraints { /// Signature for a function that is called for each [RenderObject]. /// /// Used by [RenderObject.visitChildren] and [RenderObject.visitChildrenForSemantics]. -typedef void RenderObjectVisitor(RenderObject child); +typedef RenderObjectVisitor = void Function(RenderObject child); /// Signature for a function that is called during layout. /// /// Used by [RenderObject.invokeLayoutCallback]. -typedef void LayoutCallback(T constraints); +typedef LayoutCallback = void Function(T constraints); /// A reference to the semantics tree. /// diff --git a/packages/flutter/lib/src/rendering/platform_view.dart b/packages/flutter/lib/src/rendering/platform_view.dart index f409e1e105..dc87c7703e 100644 --- a/packages/flutter/lib/src/rendering/platform_view.dart +++ b/packages/flutter/lib/src/rendering/platform_view.dart @@ -303,7 +303,7 @@ class _AndroidViewGestureRecognizer extends OneSequenceGestureRecognizer { } } -typedef Offset _GlobalToLocal(Offset point); +typedef _GlobalToLocal = Offset Function(Offset point); // Composes a stream of PointerEvent objects into AndroidMotionEvent objects // and dispatches them to the associated embedded Android view. diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 961b2499d8..46d988e799 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -922,7 +922,7 @@ class RenderAnimatedOpacity extends RenderProxyBox { /// Signature for a function that creates a [Shader] for a given [Rect]. /// /// Used by [RenderShaderMask] and the [ShaderMask] widget. -typedef Shader ShaderCallback(Rect bounds); +typedef ShaderCallback = Shader Function(Rect bounds); /// Applies a mask generated by a [Shader] to its child. /// @@ -2443,22 +2443,22 @@ class RenderFractionalTranslation extends RenderProxyBox { /// Signature for listening to [PointerDownEvent] events. /// /// Used by [Listener] and [RenderPointerListener]. -typedef void PointerDownEventListener(PointerDownEvent event); +typedef PointerDownEventListener = void Function(PointerDownEvent event); /// Signature for listening to [PointerMoveEvent] events. /// /// Used by [Listener] and [RenderPointerListener]. -typedef void PointerMoveEventListener(PointerMoveEvent event); +typedef PointerMoveEventListener = void Function(PointerMoveEvent event); /// Signature for listening to [PointerUpEvent] events. /// /// Used by [Listener] and [RenderPointerListener]. -typedef void PointerUpEventListener(PointerUpEvent event); +typedef PointerUpEventListener = void Function(PointerUpEvent event); /// Signature for listening to [PointerCancelEvent] events. /// /// Used by [Listener] and [RenderPointerListener]. -typedef void PointerCancelEventListener(PointerCancelEvent event); +typedef PointerCancelEventListener = void Function(PointerCancelEvent event); /// Calls callbacks in response to pointer events. /// diff --git a/packages/flutter/lib/src/scheduler/binding.dart b/packages/flutter/lib/src/scheduler/binding.dart index 7ac7e4f580..61f8d17447 100644 --- a/packages/flutter/lib/src/scheduler/binding.dart +++ b/packages/flutter/lib/src/scheduler/binding.dart @@ -39,13 +39,13 @@ set timeDilation(double value) { /// scheduler's epoch. Use timeStamp to determine how far to advance animation /// timelines so that all the animations in the system are synchronized to a /// common time base. -typedef void FrameCallback(Duration timeStamp); +typedef FrameCallback = void Function(Duration timeStamp); /// Signature for [Scheduler.scheduleTask] callbacks. /// /// The type argument `T` is the task's return value. Consider [void] if the /// task does not return a value. -typedef T TaskCallback(); +typedef TaskCallback = T Function(); /// Signature for the [SchedulerBinding.schedulingStrategy] callback. Called /// whenever the system needs to decide whether a task at a given @@ -55,7 +55,7 @@ typedef T TaskCallback(); /// at this time, false otherwise. /// /// See also [defaultSchedulingStrategy]. -typedef bool SchedulingStrategy({ int priority, SchedulerBinding scheduler }); +typedef SchedulingStrategy = bool Function({ int priority, SchedulerBinding scheduler }); class _TaskEntry { _TaskEntry(this.task, this.priority, this.debugLabel, this.flow) { diff --git a/packages/flutter/lib/src/scheduler/ticker.dart b/packages/flutter/lib/src/scheduler/ticker.dart index 93198a7035..a943a916d4 100644 --- a/packages/flutter/lib/src/scheduler/ticker.dart +++ b/packages/flutter/lib/src/scheduler/ticker.dart @@ -12,7 +12,7 @@ import 'binding.dart'; /// /// The argument is the time that the object had spent enabled so far /// at the time of the callback being called. -typedef void TickerCallback(Duration elapsed); +typedef TickerCallback = void Function(Duration elapsed); /// An interface implemented by classes that can vend [Ticker] objects. /// diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart index 3455bdf2db..6d956ba098 100644 --- a/packages/flutter/lib/src/semantics/semantics.dart +++ b/packages/flutter/lib/src/semantics/semantics.dart @@ -23,19 +23,19 @@ export 'semantics_event.dart'; /// Return false to stop visiting nodes. /// /// Used by [SemanticsNode.visitChildren]. -typedef bool SemanticsNodeVisitor(SemanticsNode node); +typedef SemanticsNodeVisitor = bool Function(SemanticsNode node); /// Signature for [SemanticsAction]s that move the cursor. /// /// If `extendSelection` is set to true the cursor movement should extend the /// current selection or (if nothing is currently selected) start a selection. -typedef void MoveCursorHandler(bool extendSelection); +typedef MoveCursorHandler = void Function(bool extendSelection); /// Signature for the [SemanticsAction.setSelection] handlers to change the /// text selection (or re-position the cursor) to `selection`. -typedef void SetSelectionHandler(TextSelection selection); +typedef SetSelectionHandler = void Function(TextSelection selection); -typedef void _SemanticsActionHandler(dynamic args); +typedef _SemanticsActionHandler = void Function(dynamic args); /// A tag for a [SemanticsNode]. /// diff --git a/packages/flutter/lib/src/services/platform_messages.dart b/packages/flutter/lib/src/services/platform_messages.dart index 40e3e2eb1a..ef26456be9 100644 --- a/packages/flutter/lib/src/services/platform_messages.dart +++ b/packages/flutter/lib/src/services/platform_messages.dart @@ -10,7 +10,7 @@ import 'package:flutter/foundation.dart'; import 'platform_channel.dart'; -typedef Future _MessageHandler(ByteData message); +typedef _MessageHandler = Future Function(ByteData message); /// Sends binary messages to and receives binary messages from platform plugins. /// diff --git a/packages/flutter/lib/src/services/platform_views.dart b/packages/flutter/lib/src/services/platform_views.dart index eea7115b6c..e015a98502 100644 --- a/packages/flutter/lib/src/services/platform_views.dart +++ b/packages/flutter/lib/src/services/platform_views.dart @@ -39,7 +39,7 @@ class PlatformViewsRegistry { /// Callback signature for when a platform view was created. /// /// `id` is the platform view's unique identifier. -typedef void PlatformViewCreatedCallback(int id); +typedef PlatformViewCreatedCallback = void Function(int id); /// Provides access to the platform views service. /// diff --git a/packages/flutter/lib/src/services/text_formatter.dart b/packages/flutter/lib/src/services/text_formatter.dart index 123efffafe..1eec81c9be 100644 --- a/packages/flutter/lib/src/services/text_formatter.dart +++ b/packages/flutter/lib/src/services/text_formatter.dart @@ -53,7 +53,7 @@ abstract class TextInputFormatter { /// Function signature expected for creating custom [TextInputFormatter] /// shorthands via [TextInputFormatter.withFunction]; -typedef TextEditingValue TextInputFormatFunction( +typedef TextInputFormatFunction = TextEditingValue Function( TextEditingValue oldValue, TextEditingValue newValue, ); diff --git a/packages/flutter/lib/src/widgets/animated_cross_fade.dart b/packages/flutter/lib/src/widgets/animated_cross_fade.dart index 065b75ce12..13d64f9d40 100644 --- a/packages/flutter/lib/src/widgets/animated_cross_fade.dart +++ b/packages/flutter/lib/src/widgets/animated_cross_fade.dart @@ -57,7 +57,7 @@ enum CrossFadeState { /// ); /// } /// ``` -typedef Widget AnimatedCrossFadeBuilder(Widget topChild, Key topChildKey, Widget bottomChild, Key bottomChildKey); +typedef AnimatedCrossFadeBuilder = Widget Function(Widget topChild, Key topChildKey, Widget bottomChild, Key bottomChildKey); /// A widget that cross-fades between two given children and animates itself /// between their sizes. diff --git a/packages/flutter/lib/src/widgets/animated_list.dart b/packages/flutter/lib/src/widgets/animated_list.dart index b33dafb82e..b44f471782 100644 --- a/packages/flutter/lib/src/widgets/animated_list.dart +++ b/packages/flutter/lib/src/widgets/animated_list.dart @@ -14,10 +14,10 @@ import 'scroll_view.dart'; import 'ticker_provider.dart'; /// Signature for the builder callback used by [AnimatedList]. -typedef Widget AnimatedListItemBuilder(BuildContext context, int index, Animation animation); +typedef AnimatedListItemBuilder = Widget Function(BuildContext context, int index, Animation animation); /// Signature for the builder callback used by [AnimatedListState.removeItem]. -typedef Widget AnimatedListRemovedItemBuilder(BuildContext context, Animation animation); +typedef AnimatedListRemovedItemBuilder = Widget Function(BuildContext context, Animation animation); // The default insert/remove animation duration. const Duration _kDuration = Duration(milliseconds: 300); diff --git a/packages/flutter/lib/src/widgets/animated_switcher.dart b/packages/flutter/lib/src/widgets/animated_switcher.dart index 22f00724c6..cddbcb074e 100644 --- a/packages/flutter/lib/src/widgets/animated_switcher.dart +++ b/packages/flutter/lib/src/widgets/animated_switcher.dart @@ -43,7 +43,7 @@ class _AnimatedSwitcherChildEntry { /// /// The function should return a widget which wraps the given `child`. It may /// also use the `animation` to inform its transition. It must not return null. -typedef Widget AnimatedSwitcherTransitionBuilder(Widget child, Animation animation); +typedef AnimatedSwitcherTransitionBuilder = Widget Function(Widget child, Animation animation); /// Signature for builders used to generate custom layouts for /// [AnimatedSwitcher]. @@ -55,7 +55,7 @@ typedef Widget AnimatedSwitcherTransitionBuilder(Widget child, Animation /// The `previousChildren` list is an unmodifiable list, sorted with the oldest /// at the beginning and the newest at the end. It does not include the /// `currentChild`. -typedef Widget AnimatedSwitcherLayoutBuilder(Widget currentChild, List previousChildren); +typedef AnimatedSwitcherLayoutBuilder = Widget Function(Widget currentChild, List previousChildren); /// A widget that by default does a [FadeTransition] between a new widget and /// the widget previously set on the [AnimatedSwitcher] as a child. diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index b27a0dd9da..241659863b 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -31,7 +31,7 @@ export 'dart:ui' show Locale; /// The `locale` is the device's locale when the app started, or the device /// locale the user selected after the app was started. The `supportedLocales` /// parameter is just the value of [WidgetsApp.supportedLocales]. -typedef Locale LocaleResolutionCallback(Locale locale, Iterable supportedLocales); +typedef LocaleResolutionCallback = Locale Function(Locale locale, Iterable supportedLocales); /// The signature of [WidgetsApp.onGenerateTitle]. /// @@ -41,7 +41,7 @@ typedef Locale LocaleResolutionCallback(Locale locale, Iterable supporte /// localized title. /// /// This function must not return null. -typedef String GenerateAppTitle(BuildContext context); +typedef GenerateAppTitle = String Function(BuildContext context); /// A convenience class that wraps a number of widgets that are commonly /// required for an application. diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index 19e628618b..5100b3cbe5 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -288,7 +288,7 @@ class AsyncSnapshot { /// itself based on a snapshot from interacting with a [Stream]. /// * [FutureBuilder], which delegates to an [AsyncWidgetBuilder] to build /// itself based on a snapshot from interacting with a [Future]. -typedef Widget AsyncWidgetBuilder(BuildContext context, AsyncSnapshot snapshot); +typedef AsyncWidgetBuilder = Widget Function(BuildContext context, AsyncSnapshot snapshot); /// Widget that builds itself based on the latest snapshot of interaction with /// a [Stream]. diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 9223dd9c6e..d94669a877 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -5608,7 +5608,7 @@ class Builder extends StatelessWidget { /// Signature for the builder callback used by [StatefulBuilder]. /// /// Call [setState] to schedule the [StatefulBuilder] to rebuild. -typedef Widget StatefulWidgetBuilder(BuildContext context, StateSetter setState); +typedef StatefulWidgetBuilder = Widget Function(BuildContext context, StateSetter setState); /// A platonic widget that both has state and calls a closure to obtain its child widget. /// diff --git a/packages/flutter/lib/src/widgets/dismissible.dart b/packages/flutter/lib/src/widgets/dismissible.dart index 09a9fc5d50..27b3a8f5c0 100644 --- a/packages/flutter/lib/src/widgets/dismissible.dart +++ b/packages/flutter/lib/src/widgets/dismissible.dart @@ -20,7 +20,7 @@ const double _kDismissThreshold = 0.4; /// the given `direction`. /// /// Used by [Dismissible.onDismissed]. -typedef void DismissDirectionCallback(DismissDirection direction); +typedef DismissDirectionCallback = void Function(DismissDirection direction); /// The direction in which a [Dismissible] can be dismissed. enum DismissDirection { diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index 329114b385..ba289f507d 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -14,12 +14,12 @@ import 'overlay.dart'; /// Signature for determining whether the given data will be accepted by a [DragTarget]. /// /// Used by [DragTarget.onWillAccept]. -typedef bool DragTargetWillAccept(T data); +typedef DragTargetWillAccept = bool Function(T data); /// Signature for causing a [DragTarget] to accept the given data. /// /// Used by [DragTarget.onAccept]. -typedef void DragTargetAccept(T data); +typedef DragTargetAccept = void Function(T data); /// Signature for building children of a [DragTarget]. /// @@ -29,17 +29,17 @@ typedef void DragTargetAccept(T data); /// this [DragTarget] and that will not be accepted by the [DragTarget]. /// /// Used by [DragTarget.builder]. -typedef Widget DragTargetBuilder(BuildContext context, List candidateData, List rejectedData); +typedef DragTargetBuilder = Widget Function(BuildContext context, List candidateData, List rejectedData); /// Signature for when a [Draggable] is dropped without being accepted by a [DragTarget]. /// /// Used by [Draggable.onDraggableCanceled]. -typedef void DraggableCanceledCallback(Velocity velocity, Offset offset); +typedef DraggableCanceledCallback = void Function(Velocity velocity, Offset offset); /// Signature for when a [Draggable] leaves a [DragTarget]. /// /// Used by [DragTarget.onLeave]. -typedef void DragTargetLeave(T data); +typedef DragTargetLeave = void Function(T data); /// Where the [Draggable] should be anchored during a drag. enum DragAnchor { @@ -501,7 +501,7 @@ class _DragTargetState extends State> { } enum _DragEndKind { dropped, canceled } -typedef void _OnDragEnd(Velocity velocity, Offset offset, bool wasAccepted); +typedef _OnDragEnd = void Function(Velocity velocity, Offset offset, bool wasAccepted); // The lifetime of this object is a little dubious right now. Specifically, it // lives as long as the pointer is down. Arguably it should self-immolate if the diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index 0fdb6980dc..3c79cc6ac3 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -27,7 +27,7 @@ export 'package:flutter/rendering.dart' show SelectionChangedCause; /// Signature for the callback that reports when the user changes the selection /// (including the cursor location). -typedef void SelectionChangedCallback(TextSelection selection, SelectionChangedCause cause); +typedef SelectionChangedCallback = void Function(TextSelection selection, SelectionChangedCause cause); const Duration _kCursorBlinkHalfPeriod = Duration(milliseconds: 500); diff --git a/packages/flutter/lib/src/widgets/fade_in_image.dart b/packages/flutter/lib/src/widgets/fade_in_image.dart index b0b9b41531..4ce4599721 100644 --- a/packages/flutter/lib/src/widgets/fade_in_image.dart +++ b/packages/flutter/lib/src/widgets/fade_in_image.dart @@ -311,7 +311,7 @@ enum FadeInImagePhase { completed, } -typedef void _ImageProviderResolverListener(); +typedef _ImageProviderResolverListener = void Function(); class _ImageProviderResolver { _ImageProviderResolver({ diff --git a/packages/flutter/lib/src/widgets/form.dart b/packages/flutter/lib/src/widgets/form.dart index a562a785e2..ff0d5daa6c 100644 --- a/packages/flutter/lib/src/widgets/form.dart +++ b/packages/flutter/lib/src/widgets/form.dart @@ -183,17 +183,17 @@ class _FormScope extends InheritedWidget { /// Signature for validating a form field. /// /// Used by [FormField.validator]. -typedef String FormFieldValidator(T value); +typedef FormFieldValidator = String Function(T value); /// Signature for being notified when a form field changes value. /// /// Used by [FormField.onSaved]. -typedef void FormFieldSetter(T newValue); +typedef FormFieldSetter = void Function(T newValue); /// Signature for building the widget representing the form field. /// /// Used by [FormField.builder]. -typedef Widget FormFieldBuilder(FormFieldState field); +typedef FormFieldBuilder = Widget Function(FormFieldState field); /// A single form field. /// diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 445fe88260..faf15622c2 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -829,7 +829,7 @@ enum _StateLifecycle { } /// The signature of [State.setState] functions. -typedef void StateSetter(VoidCallback fn); +typedef StateSetter = void Function(VoidCallback fn); /// The logic and internal state for a [StatefulWidget]. /// @@ -1751,7 +1751,7 @@ class _InactiveElements { /// /// It is safe to call `element.visitChildElements` reentrantly within /// this callback. -typedef void ElementVisitor(Element element); +typedef ElementVisitor = void Function(Element element); /// A handle to the location of a widget in the widget tree. /// @@ -3554,7 +3554,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { /// * [FlutterError.reportError], which is typically called with the same /// [FlutterErrorDetails] object immediately prior to [ErrorWidget.builder] /// being called. -typedef Widget ErrorWidgetBuilder(FlutterErrorDetails details); +typedef ErrorWidgetBuilder = Widget Function(FlutterErrorDetails details); /// A widget that renders an exception's message. /// @@ -3617,13 +3617,13 @@ class ErrorWidget extends LeafRenderObjectWidget { /// or [State.build]. /// /// Used by [Builder.builder], [OverlayEntry.builder], etc. -typedef Widget WidgetBuilder(BuildContext context); +typedef WidgetBuilder = Widget Function(BuildContext context); /// Signature for a function that creates a widget for a given index, e.g., in a /// list. /// /// Used by [ListView.builder] and other APIs that use lazily-generated widgets. -typedef Widget IndexedWidgetBuilder(BuildContext context, int index); +typedef IndexedWidgetBuilder = Widget Function(BuildContext context, int index); /// A builder that builds a widget given a child. /// @@ -3631,7 +3631,7 @@ typedef Widget IndexedWidgetBuilder(BuildContext context, int index); /// /// Used by [AnimatedBuilder.builder], as well as [WidgetsApp.builder] and /// [MaterialApp.builder]. -typedef Widget TransitionBuilder(BuildContext context, Widget child); +typedef TransitionBuilder = Widget Function(BuildContext context, Widget child); /// An [Element] that composes other [Element]s. /// diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index dc0709a0c6..8006a07c5f 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -61,10 +61,10 @@ abstract class GestureRecognizerFactory { } /// Signature for closures that implement [GestureRecognizerFactory.constructor]. -typedef T GestureRecognizerFactoryConstructor(); +typedef GestureRecognizerFactoryConstructor = T Function(); /// Signature for closures that implement [GestureRecognizerFactory.initializer]. -typedef void GestureRecognizerFactoryInitializer(T instance); +typedef GestureRecognizerFactoryInitializer = void Function(T instance); /// Factory for creating gesture recognizers that delegates to callbacks. /// diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index 97bcbfcfe9..a5a63297d1 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -18,12 +18,12 @@ import 'transitions.dart'; /// This is typically used with a [HeroController] to provide an animation for /// [Hero] positions that looks nicer than a linear movement. For example, see /// [MaterialRectArcTween]. -typedef Tween CreateRectTween(Rect begin, Rect end); +typedef CreateRectTween = Tween Function(Rect begin, Rect end); /// A function that lets [Hero]s self supply a [Widget] that is shown during the /// hero's flight from one route to another instead of default (which is to /// show the destination route's instance of the Hero). -typedef Widget HeroFlightShuttleBuilder( +typedef HeroFlightShuttleBuilder = Widget Function( BuildContext flightContext, Animation animation, HeroFlightDirection flightDirection, @@ -31,7 +31,7 @@ typedef Widget HeroFlightShuttleBuilder( BuildContext toHeroContext, ); -typedef void _OnFlightEnded(_HeroFlight flight); +typedef _OnFlightEnded = void Function(_HeroFlight flight); /// Direction of the hero's flight based on the navigation operation. enum HeroFlightDirection { diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 3b32f66580..7bf804d717 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -243,10 +243,10 @@ abstract class ImplicitlyAnimatedWidget extends StatefulWidget { /// /// This is the type of one of the arguments of [TweenVisitor], the signature /// used by [AnimatedWidgetBaseState.forEachTween]. -typedef Tween TweenConstructor(T targetValue); +typedef TweenConstructor = Tween Function(T targetValue); /// Signature for callbacks passed to [AnimatedWidgetBaseState.forEachTween]. -typedef Tween TweenVisitor(Tween tween, T targetValue, TweenConstructor constructor); +typedef TweenVisitor = Tween Function(Tween tween, T targetValue, TweenConstructor constructor); /// A base class for widgets with implicit animations. /// diff --git a/packages/flutter/lib/src/widgets/layout_builder.dart b/packages/flutter/lib/src/widgets/layout_builder.dart index 2b8f9cf566..7c16d98661 100644 --- a/packages/flutter/lib/src/widgets/layout_builder.dart +++ b/packages/flutter/lib/src/widgets/layout_builder.dart @@ -9,7 +9,7 @@ import 'debug.dart'; import 'framework.dart'; /// The signature of the [LayoutBuilder] builder function. -typedef Widget LayoutWidgetBuilder(BuildContext context, BoxConstraints constraints); +typedef LayoutWidgetBuilder = Widget Function(BuildContext context, BoxConstraints constraints); /// Builds a widget tree that can depend on the parent widget's size. /// diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 5a0ae55871..b4182405c6 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -23,16 +23,16 @@ import 'ticker_provider.dart'; /// Creates a route for the given route settings. /// /// Used by [Navigator.onGenerateRoute] and [Navigator.onUnknownRoute]. -typedef Route RouteFactory(RouteSettings settings); +typedef RouteFactory = Route Function(RouteSettings settings); /// Signature for the [Navigator.popUntil] predicate argument. -typedef bool RoutePredicate(Route route); +typedef RoutePredicate = bool Function(Route route); /// Signature for a callback that verifies that it's OK to call [Navigator.pop]. /// /// Used by [Form.onWillPop], [ModalRoute.addScopedWillPopCallback], /// [ModalRoute.removeScopedWillPopCallback], and [WillPopScope]. -typedef Future WillPopCallback(); +typedef WillPopCallback = Future Function(); /// Indicates whether the current route should be popped. /// diff --git a/packages/flutter/lib/src/widgets/nested_scroll_view.dart b/packages/flutter/lib/src/widgets/nested_scroll_view.dart index 04b6b49242..9d7d98e719 100644 --- a/packages/flutter/lib/src/widgets/nested_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/nested_scroll_view.dart @@ -34,7 +34,7 @@ import 'viewport.dart'; /// [SliverAppBar.forceElevated] property to ensure that the app bar shows a /// shadow, since it would otherwise not necessarily be aware that it had /// content ostensibly below it. -typedef List NestedScrollViewHeaderSliversBuilder(BuildContext context, bool innerBoxIsScrolled); +typedef NestedScrollViewHeaderSliversBuilder = List Function(BuildContext context, bool innerBoxIsScrolled); /// A scrolling view inside of which can be nested other scrolling views, with /// their scroll positions being intrinsically linked. @@ -454,7 +454,7 @@ class _NestedScrollMetrics extends FixedScrollMetrics { final double correctionOffset; } -typedef ScrollActivity _NestedScrollActivityGetter(_NestedScrollPosition position); +typedef _NestedScrollActivityGetter = ScrollActivity Function(_NestedScrollPosition position); class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldController { _NestedScrollCoordinator(this._state, this._parent, this._onHasScrolledBodyChanged) { diff --git a/packages/flutter/lib/src/widgets/notification_listener.dart b/packages/flutter/lib/src/widgets/notification_listener.dart index 66f743d82c..f1be92ae72 100644 --- a/packages/flutter/lib/src/widgets/notification_listener.dart +++ b/packages/flutter/lib/src/widgets/notification_listener.dart @@ -10,7 +10,7 @@ import 'framework.dart'; /// notification to continue to be dispatched to further ancestors. /// /// Used by [NotificationListener.onNotification]. -typedef bool NotificationListenerCallback(T notification); +typedef NotificationListenerCallback = bool Function(T notification); /// A notification that can bubble up the widget tree. /// diff --git a/packages/flutter/lib/src/widgets/orientation_builder.dart b/packages/flutter/lib/src/widgets/orientation_builder.dart index 0a9ba16a55..3c8a6f75c5 100644 --- a/packages/flutter/lib/src/widgets/orientation_builder.dart +++ b/packages/flutter/lib/src/widgets/orientation_builder.dart @@ -10,7 +10,7 @@ import 'media_query.dart'; /// Signature for a function that builds a widget given an [Orientation]. /// /// Used by [OrientationBuilder.builder]. -typedef Widget OrientationWidgetBuilder(BuildContext context, Orientation orientation); +typedef OrientationWidgetBuilder = Widget Function(BuildContext context, Orientation orientation); /// Builds a widget tree that can depend on the parent widget's orientation /// (distinct from the device orientation). diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index fd1fde39cd..252b4cca67 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -1529,10 +1529,10 @@ Future showGeneralDialog({ /// Used in [PageRouteBuilder] and [showGeneralDialog]. /// /// See [ModalRoute.buildPage] for complete definition of the parameters. -typedef Widget RoutePageBuilder(BuildContext context, Animation animation, Animation secondaryAnimation); +typedef RoutePageBuilder = Widget Function(BuildContext context, Animation animation, Animation secondaryAnimation); /// Signature for the function that builds a route's transitions. /// Used in [PageRouteBuilder] and [showGeneralDialog]. /// /// See [ModalRoute.buildTransitions] for complete definition of the parameters. -typedef Widget RouteTransitionsBuilder(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child); +typedef RouteTransitionsBuilder = Widget Function(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child); diff --git a/packages/flutter/lib/src/widgets/scroll_notification.dart b/packages/flutter/lib/src/widgets/scroll_notification.dart index 8ab378aca7..ba85032ea6 100644 --- a/packages/flutter/lib/src/widgets/scroll_notification.dart +++ b/packages/flutter/lib/src/widgets/scroll_notification.dart @@ -284,7 +284,7 @@ class UserScrollNotification extends ScrollNotification { /// A predicate for [ScrollNotification], used to customize widgets that /// listen to notifications from their children. -typedef bool ScrollNotificationPredicate(ScrollNotification notification); +typedef ScrollNotificationPredicate = bool Function(ScrollNotification notification); /// A [ScrollNotificationPredicate] that checks whether /// `notification.depth == 0`, which means that the notification did not bubble diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index 4cfb559aa0..fac04a306b 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -25,7 +25,7 @@ export 'package:flutter/physics.dart' show Tolerance; /// Signature used by [Scrollable] to build the viewport through which the /// scrollable content is displayed. -typedef Widget ViewportBuilder(BuildContext context, ViewportOffset position); +typedef ViewportBuilder = Widget Function(BuildContext context, ViewportOffset position); /// A widget that scrolls. /// diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index 91f3710ec6..f2019c2c76 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -60,7 +60,7 @@ enum _TextSelectionHandlePosition { start, end } /// of the [RenderBox] given by the [TextSelectionOverlay.renderObject]. /// /// Used by [TextSelectionOverlay.onSelectionOverlayChanged]. -typedef void TextSelectionOverlayChanged(TextEditingValue value, Rect caretRect); +typedef TextSelectionOverlayChanged = void Function(TextEditingValue value, Rect caretRect); /// An interface for building the selection UI, to be provided by the /// implementor of the toolbar widget. diff --git a/packages/flutter/lib/src/widgets/value_listenable_builder.dart b/packages/flutter/lib/src/widgets/value_listenable_builder.dart index 5ab391956f..21073b5875 100644 --- a/packages/flutter/lib/src/widgets/value_listenable_builder.dart +++ b/packages/flutter/lib/src/widgets/value_listenable_builder.dart @@ -16,7 +16,7 @@ import 'framework.dart'; /// /// * [ValueListenableBuilder], a widget which invokes this builder each time /// a [ValueListenable] changes value. -typedef Widget ValueWidgetBuilder(BuildContext context, T value, Widget child); +typedef ValueWidgetBuilder = Widget Function(BuildContext context, T value, Widget child); /// A widget whose content stays sync'ed with a [ValueListenable]. /// diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index 9228dd4b01..09683a8165 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -36,9 +36,9 @@ import 'icon_data.dart'; /// Signature for the builder callback used by /// [WidgetInspector.selectButtonBuilder]. -typedef Widget InspectorSelectButtonBuilder(BuildContext context, VoidCallback onPressed); +typedef InspectorSelectButtonBuilder = Widget Function(BuildContext context, VoidCallback onPressed); -typedef void _RegisterServiceExtensionCallback({ +typedef _RegisterServiceExtensionCallback = void Function({ @required String name, @required ServiceExtensionCallback callback }); @@ -655,7 +655,7 @@ List<_DiagnosticsPathNode> _followDiagnosticableChain(List chain /// Signature for the selection change callback used by /// [WidgetInspectorService.selectionChangedCallback]. -typedef void InspectorSelectionChangedCallback(); +typedef InspectorSelectionChangedCallback = void Function(); /// Structure to help reference count Dart objects referenced by a GUI tool /// using [WidgetInspectorService]. diff --git a/packages/flutter/test/gestures/arena_test.dart b/packages/flutter/test/gestures/arena_test.dart index 160b77bcb5..187ea0ec1b 100644 --- a/packages/flutter/test/gestures/arena_test.dart +++ b/packages/flutter/test/gestures/arena_test.dart @@ -6,7 +6,7 @@ import 'package:flutter/gestures.dart'; import '../flutter_test_alternative.dart'; -typedef void GestureArenaCallback(Object key); +typedef GestureArenaCallback = void Function(Object key); const int primaryKey = 4; diff --git a/packages/flutter/test/gestures/gesture_binding_test.dart b/packages/flutter/test/gestures/gesture_binding_test.dart index a0f53f8825..8db85da591 100644 --- a/packages/flutter/test/gestures/gesture_binding_test.dart +++ b/packages/flutter/test/gestures/gesture_binding_test.dart @@ -9,7 +9,7 @@ import 'package:flutter/gestures.dart'; import '../flutter_test_alternative.dart'; -typedef void HandleEventCallback(PointerEvent event); +typedef HandleEventCallback = void Function(PointerEvent event); class TestGestureFlutterBinding extends BindingBase with GestureBinding { HandleEventCallback callback; diff --git a/packages/flutter/test/gestures/gesture_tester.dart b/packages/flutter/test/gestures/gesture_tester.dart index d282c051a6..5e095315b8 100644 --- a/packages/flutter/test/gestures/gesture_tester.dart +++ b/packages/flutter/test/gestures/gesture_tester.dart @@ -32,7 +32,7 @@ class GestureTester { } } -typedef void GestureTest(GestureTester tester); +typedef GestureTest = void Function(GestureTester tester); @isTest void testGesture(String description, GestureTest callback) { diff --git a/packages/flutter/test/gestures/locking_test.dart b/packages/flutter/test/gestures/locking_test.dart index f08d714be9..8bb75b5e4c 100644 --- a/packages/flutter/test/gestures/locking_test.dart +++ b/packages/flutter/test/gestures/locking_test.dart @@ -10,7 +10,7 @@ import 'package:flutter/gestures.dart'; import '../flutter_test_alternative.dart'; -typedef void HandleEventCallback(PointerEvent event); +typedef HandleEventCallback = void Function(PointerEvent event); class TestGestureFlutterBinding extends BindingBase with GestureBinding { HandleEventCallback callback; diff --git a/packages/flutter/test/gestures/team_test.dart b/packages/flutter/test/gestures/team_test.dart index e39a494fa6..529d6b9faf 100644 --- a/packages/flutter/test/gestures/team_test.dart +++ b/packages/flutter/test/gestures/team_test.dart @@ -103,7 +103,7 @@ void main() { }); } -typedef void GestureAcceptedCallback(); +typedef GestureAcceptedCallback = void Function(); class PassiveGestureRecognizer extends OneSequenceGestureRecognizer { GestureAcceptedCallback onGestureAccepted; diff --git a/packages/flutter/test/material/feedback_test.dart b/packages/flutter/test/material/feedback_test.dart index c17e0e377c..603ed2c887 100644 --- a/packages/flutter/test/material/feedback_test.dart +++ b/packages/flutter/test/material/feedback_test.dart @@ -224,4 +224,4 @@ class TestWidget extends StatelessWidget { } } -typedef VoidCallback HandlerCreator(BuildContext context); +typedef HandlerCreator = VoidCallback Function(BuildContext context); diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 96ca887660..81dc96b811 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -86,7 +86,7 @@ Widget buildFrame({ ); } -typedef Widget TabControllerFrameBuilder(BuildContext context, TabController controller); +typedef TabControllerFrameBuilder = Widget Function(BuildContext context, TabController controller); class TabControllerFrame extends StatefulWidget { const TabControllerFrame({ this.length, this.initialIndex = 0, this.builder }); diff --git a/packages/flutter/test/rendering/mock_canvas.dart b/packages/flutter/test/rendering/mock_canvas.dart index de9410a96c..5dc2cac01f 100644 --- a/packages/flutter/test/rendering/mock_canvas.dart +++ b/packages/flutter/test/rendering/mock_canvas.dart @@ -64,13 +64,13 @@ Matcher paintsExactlyCountTimes(Symbol methodName, int count) { /// ```dart /// if (methodName == #drawCircle) { ... } /// ``` -typedef bool PaintPatternPredicate(Symbol methodName, List arguments); +typedef PaintPatternPredicate = bool Function(Symbol methodName, List arguments); /// The signature of [RenderObject.paint] functions. -typedef void _ContextPainterFunction(PaintingContext context, Offset offset); +typedef _ContextPainterFunction = void Function(PaintingContext context, Offset offset); /// The signature of functions that paint directly on a canvas. -typedef void _CanvasPainterFunction(Canvas canvas); +typedef _CanvasPainterFunction = void Function(Canvas canvas); /// Builder interface for patterns used to match display lists (canvas calls). /// diff --git a/packages/flutter/test/widgets/dismissible_test.dart b/packages/flutter/test/widgets/dismissible_test.dart index 2745af0046..71e19d832d 100644 --- a/packages/flutter/test/widgets/dismissible_test.dart +++ b/packages/flutter/test/widgets/dismissible_test.dart @@ -61,7 +61,7 @@ Widget buildTest({ double startToEndThreshold, TextDirection textDirection = Tex ); } -typedef Future DismissMethod(WidgetTester tester, Finder finder, { @required AxisDirection gestureDirection }); +typedef DismissMethod = Future Function(WidgetTester tester, Finder finder, { @required AxisDirection gestureDirection }); Future dismissElement(WidgetTester tester, Finder finder, { @required AxisDirection gestureDirection }) async { Offset downLocation; diff --git a/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart b/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart index a9e4c5662b..fdc8747078 100644 --- a/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart +++ b/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart @@ -5,7 +5,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; -typedef void TestCallback(BuildContext context); +typedef TestCallback = void Function(BuildContext context); class TestWidget extends StatefulWidget { const TestWidget(this.callback); diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index 14546dc693..8c9577f3ca 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -42,7 +42,7 @@ class SecondWidgetState extends State { } } -typedef void ExceptionCallback(dynamic exception); +typedef ExceptionCallback = void Function(dynamic exception); class ThirdWidget extends StatelessWidget { const ThirdWidget({ this.targetKey, this.onException }); @@ -89,7 +89,7 @@ class OnTapPage extends StatelessWidget { } } -typedef void OnObservation(Route route, Route previousRoute); +typedef OnObservation = void Function(Route route, Route previousRoute); class TestObserver extends NavigatorObserver { OnObservation onPushed; diff --git a/packages/flutter/test/widgets/semantics_traversal_test.dart b/packages/flutter/test/widgets/semantics_traversal_test.dart index f50a550c79..5a6801c862 100644 --- a/packages/flutter/test/widgets/semantics_traversal_test.dart +++ b/packages/flutter/test/widgets/semantics_traversal_test.dart @@ -14,7 +14,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'semantics_tester.dart'; -typedef Future TraversalTestFunction(TraversalTester tester); +typedef TraversalTestFunction = Future Function(TraversalTester tester); const Size tenByTen = Size(10.0, 10.0); void main() { diff --git a/packages/flutter/test/widgets/shape_decoration_test.dart b/packages/flutter/test/widgets/shape_decoration_test.dart index 64c27bdf76..08dc3a1a8c 100644 --- a/packages/flutter/test/widgets/shape_decoration_test.dart +++ b/packages/flutter/test/widgets/shape_decoration_test.dart @@ -105,7 +105,7 @@ Future main() async { }); } -typedef void Logger(String caller); +typedef Logger = void Function(String caller); class TestBorder extends ShapeBorder { const TestBorder(this.onLog) : assert(onLog != null); diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index d43adb0f43..1816a30cc9 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -12,7 +12,7 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; -typedef FutureOr> InspectorServiceExtensionCallback(Map parameters); +typedef InspectorServiceExtensionCallback = FutureOr> Function(Map parameters); class RenderRepaintBoundaryWithDebugPaint extends RenderRepaintBoundary { @override diff --git a/packages/flutter_driver/lib/src/driver/driver.dart b/packages/flutter_driver/lib/src/driver/driver.dart index 61d9364bb9..fc8cc39cb0 100644 --- a/packages/flutter_driver/lib/src/driver/driver.dart +++ b/packages/flutter_driver/lib/src/driver/driver.dart @@ -111,7 +111,7 @@ const CommonFinders find = CommonFinders._(); /// If computation is asynchronous, the function may return a [Future]. /// /// See also [FlutterDriver.waitFor]. -typedef dynamic EvaluatorFunction(); +typedef EvaluatorFunction = dynamic Function(); /// Drives a Flutter Application running in another process. class FlutterDriver { @@ -784,7 +784,7 @@ class VMServiceClientConnection { } /// A function that connects to a Dart VM service given the [url]. -typedef Future VMServiceConnectFunction(String url); +typedef VMServiceConnectFunction = Future Function(String url); /// The connection function used by [FlutterDriver.connect]. /// diff --git a/packages/flutter_driver/lib/src/extension/extension.dart b/packages/flutter_driver/lib/src/extension/extension.dart index 2808d5c4ac..bc79c9926c 100644 --- a/packages/flutter_driver/lib/src/extension/extension.dart +++ b/packages/flutter_driver/lib/src/extension/extension.dart @@ -34,7 +34,7 @@ const String _extensionMethod = 'ext.flutter.$_extensionMethodName'; /// /// Messages are described in string form and should return a [Future] which /// eventually completes to a string response. -typedef Future DataHandler(String message); +typedef DataHandler = Future Function(String message); class _DriverBinding extends BindingBase with ServicesBinding, SchedulerBinding, GestureBinding, PaintingBinding, SemanticsBinding, RendererBinding, WidgetsBinding { _DriverBinding(this._handler, this._silenceErrors); @@ -75,14 +75,14 @@ void enableFlutterDriverExtension({ DataHandler handler, bool silenceErrors = fa } /// Signature for functions that handle a command and return a result. -typedef Future CommandHandlerCallback(Command c); +typedef CommandHandlerCallback = Future Function(Command c); /// Signature for functions that deserialize a JSON map to a command object. -typedef Command CommandDeserializerCallback(Map params); +typedef CommandDeserializerCallback = Command Function(Map params); /// Signature for functions that run the given finder and return the [Element] /// found, if any, or null otherwise. -typedef Finder FinderConstructor(SerializableFinder finder); +typedef FinderConstructor = Finder Function(SerializableFinder finder); /// The class that manages communication between a Flutter Driver test and the /// application being remote-controlled, on the application side. diff --git a/packages/flutter_test/lib/src/finders.dart b/packages/flutter_test/lib/src/finders.dart index 2f0c4bf7f6..6341190d4e 100644 --- a/packages/flutter_test/lib/src/finders.dart +++ b/packages/flutter_test/lib/src/finders.dart @@ -9,10 +9,10 @@ import 'package:meta/meta.dart'; import 'all_elements.dart'; /// Signature for [CommonFinders.byWidgetPredicate]. -typedef bool WidgetPredicate(Widget widget); +typedef WidgetPredicate = bool Function(Widget widget); /// Signature for [CommonFinders.byElementPredicate]. -typedef bool ElementPredicate(Element element); +typedef ElementPredicate = bool Function(Element element); /// Some frequently used widget [Finder]s. const CommonFinders find = CommonFinders._(); diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 18d68acc5b..d348d80157 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -865,7 +865,7 @@ class _HasGoodToStringDeep extends Matcher { /// /// This makes it useful for comparing numbers, [Color]s, [Offset]s and other /// sets of value for which a metric space is defined. -typedef num DistanceFunction(T a, T b); +typedef DistanceFunction = num Function(T a, T b); /// The type of a union of instances of [DistanceFunction] for various types /// T. @@ -878,7 +878,7 @@ typedef num DistanceFunction(T a, T b); /// /// Calling an instance of this type must either be done dynamically, or by /// first casting it to a [DistanceFunction] for some concrete T. -typedef num AnyDistanceFunction(Null a, Null b); +typedef AnyDistanceFunction = num Function(Null a, Null b); const Map _kStandardDistanceFunctions = { Color: _maxComponentColorDistance, diff --git a/packages/flutter_test/lib/src/test_exception_reporter.dart b/packages/flutter_test/lib/src/test_exception_reporter.dart index ac50aa4f45..6d79f7482c 100644 --- a/packages/flutter_test/lib/src/test_exception_reporter.dart +++ b/packages/flutter_test/lib/src/test_exception_reporter.dart @@ -7,7 +7,7 @@ import 'package:stack_trace/stack_trace.dart' as stack_trace; import 'package:test/test.dart' as test_package; /// Signature for the [reportTestException] callback. -typedef void TestExceptionReporter(FlutterErrorDetails details, String testDescription); +typedef TestExceptionReporter = void Function(FlutterErrorDetails details, String testDescription); /// A function that is called by the test framework when an unexpected error /// occurred during a test. diff --git a/packages/flutter_test/lib/src/test_pointer.dart b/packages/flutter_test/lib/src/test_pointer.dart index f0ef3b0561..063440e139 100644 --- a/packages/flutter_test/lib/src/test_pointer.dart +++ b/packages/flutter_test/lib/src/test_pointer.dart @@ -113,10 +113,10 @@ class TestPointer { /// Signature for a callback that can dispatch events and returns a future that /// completes when the event dispatch is complete. -typedef Future EventDispatcher(PointerEvent event, HitTestResult result); +typedef EventDispatcher = Future Function(PointerEvent event, HitTestResult result); /// Signature for callbacks that perform hit-testing at a given location. -typedef HitTestResult HitTester(Offset location); +typedef HitTester = HitTestResult Function(Offset location); /// A class for performing gestures in tests. /// diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index df32b7819a..4a766fc171 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -30,7 +30,7 @@ export 'package:test/test.dart' hide isInstanceOf; // we have our own wrapper in matchers.dart /// Signature for callback to [testWidgets] and [benchmarkWidgets]. -typedef Future WidgetTesterCallback(WidgetTester widgetTester); +typedef WidgetTesterCallback = Future Function(WidgetTester widgetTester); /// Runs the [callback] inside the Flutter test environment. /// @@ -656,7 +656,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker } } -typedef void _TickerDisposeCallback(_TestTicker ticker); +typedef _TickerDisposeCallback = void Function(_TestTicker ticker); class _TestTicker extends Ticker { _TestTicker(TickerCallback onTick, this._onDispose) : super(onTick); diff --git a/packages/flutter_tools/lib/src/base/context.dart b/packages/flutter_tools/lib/src/base/context.dart index 2f8fca10b0..df3de183ae 100644 --- a/packages/flutter_tools/lib/src/base/context.dart +++ b/packages/flutter_tools/lib/src/base/context.dart @@ -11,7 +11,7 @@ import 'package:meta/meta.dart'; /// /// Generators are allowed to return `null`, in which case the context will /// store the `null` value as the value for that type. -typedef dynamic Generator(); +typedef Generator = dynamic Function(); /// An exception thrown by [AppContext] when you try to get a [Type] value from /// the context, and the instantiation of the value results in a dependency diff --git a/packages/flutter_tools/lib/src/base/fingerprint.dart b/packages/flutter_tools/lib/src/base/fingerprint.dart index 4d33ba4584..fed1cbf804 100644 --- a/packages/flutter_tools/lib/src/base/fingerprint.dart +++ b/packages/flutter_tools/lib/src/base/fingerprint.dart @@ -13,7 +13,7 @@ import '../globals.dart'; import '../version.dart'; import 'file_system.dart'; -typedef bool FingerprintPathFilter(String path); +typedef FingerprintPathFilter = bool Function(String path); /// A tool that can be used to compute, compare, and write [Fingerprint]s for a /// set of input files and associated build settings. diff --git a/packages/flutter_tools/lib/src/base/io.dart b/packages/flutter_tools/lib/src/base/io.dart index 4beb040bc7..b26e20edca 100644 --- a/packages/flutter_tools/lib/src/base/io.dart +++ b/packages/flutter_tools/lib/src/base/io.dart @@ -77,7 +77,7 @@ export 'dart:io' WebSocketTransformer; /// Exits the process with the given [exitCode]. -typedef void ExitFunction(int exitCode); +typedef ExitFunction = void Function(int exitCode); const ExitFunction _defaultExitFunction = io.exit; diff --git a/packages/flutter_tools/lib/src/base/logger.dart b/packages/flutter_tools/lib/src/base/logger.dart index d71d97440b..a9d09d46bd 100644 --- a/packages/flutter_tools/lib/src/base/logger.dart +++ b/packages/flutter_tools/lib/src/base/logger.dart @@ -13,7 +13,7 @@ import 'utils.dart'; const int kDefaultStatusPadding = 59; -typedef void VoidCallback(); +typedef VoidCallback = void Function(); abstract class Logger { bool get isVerbose => false; diff --git a/packages/flutter_tools/lib/src/base/net.dart b/packages/flutter_tools/lib/src/base/net.dart index 1f761f3c43..94c724ed22 100644 --- a/packages/flutter_tools/lib/src/base/net.dart +++ b/packages/flutter_tools/lib/src/base/net.dart @@ -11,7 +11,7 @@ import 'io.dart'; const int kNetworkProblemExitCode = 50; -typedef HttpClient HttpClientFactory(); +typedef HttpClientFactory = HttpClient Function(); /// Download a file from the given URL and return the bytes. Future> fetchUrl(Uri url) async { diff --git a/packages/flutter_tools/lib/src/base/process.dart b/packages/flutter_tools/lib/src/base/process.dart index 09c146c02e..caf6349f81 100644 --- a/packages/flutter_tools/lib/src/base/process.dart +++ b/packages/flutter_tools/lib/src/base/process.dart @@ -11,10 +11,10 @@ import 'io.dart'; import 'process_manager.dart'; import 'utils.dart'; -typedef String StringConverter(String string); +typedef StringConverter = String Function(String string); /// A function that will be run before the VM exits. -typedef Future ShutdownHook(); +typedef ShutdownHook = Future Function(); // TODO(ianh): We have way too many ways to run subprocesses in this project. // Convert most of these into one or more lightweight wrappers around the diff --git a/packages/flutter_tools/lib/src/base/utils.dart b/packages/flutter_tools/lib/src/base/utils.dart index 8b22e86671..102a0ec5ad 100644 --- a/packages/flutter_tools/lib/src/base/utils.dart +++ b/packages/flutter_tools/lib/src/base/utils.dart @@ -251,7 +251,7 @@ Map castStringKeyedMap(dynamic untyped) { Clock get clock => context[Clock]; -typedef Future AsyncCallback(); +typedef AsyncCallback = Future Function(); /// A [Timer] inspired class that: /// - has a different initial value for the first callback delay diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index 2a91d94708..81337c9eb2 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -73,9 +73,9 @@ class DaemonCommand extends FlutterCommand { } } -typedef void DispatchCommand(Map command); +typedef DispatchCommand = void Function(Map command); -typedef Future CommandHandler(Map args); +typedef CommandHandler = Future Function(Map args); class Daemon { Daemon( @@ -305,7 +305,7 @@ class DaemonDomain extends Domain { } } -typedef Future _RunOrAttach({ +typedef _RunOrAttach = Future Function({ Completer connectionInfoCompleter, Completer appStartedCompleter }); @@ -553,7 +553,7 @@ class AppDomain extends Domain { } } -typedef void _DeviceEventHandler(Device device); +typedef _DeviceEventHandler = void Function(Device device); /// This domain lets callers list and monitor connected devices. /// diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart index 61f8d11a8e..419371a423 100644 --- a/packages/flutter_tools/lib/src/commands/drive.dart +++ b/packages/flutter_tools/lib/src/commands/drive.dart @@ -179,7 +179,7 @@ class DriveCommand extends RunCommandBase { } /// Finds a device to test on. May launch a simulator, if necessary. -typedef Future TargetDeviceFinder(); +typedef TargetDeviceFinder = Future Function(); TargetDeviceFinder targetDeviceFinder = findTargetDevice; void restoreTargetDeviceFinder() { targetDeviceFinder = findTargetDevice; @@ -213,7 +213,7 @@ Future findTargetDevice() async { } /// Starts the application on the device given command configuration. -typedef Future AppStarter(DriveCommand command); +typedef AppStarter = Future Function(DriveCommand command); AppStarter appStarter = _startApp; // (mutable for testing) void restoreAppStarter() { @@ -272,7 +272,7 @@ Future _startApp(DriveCommand command) async { } /// Runs driver tests. -typedef Future TestRunner(List testArgs, String observatoryUri); +typedef TestRunner = Future Function(List testArgs, String observatoryUri); TestRunner testRunner = _runTests; void restoreTestRunner() { testRunner = _runTests; @@ -299,7 +299,7 @@ Future _runTests(List testArgs, String observatoryUri) async { /// Stops the application. -typedef Future AppStopper(DriveCommand command); +typedef AppStopper = Future Function(DriveCommand command); AppStopper appStopper = _stopApp; void restoreAppStopper() { appStopper = _stopApp; diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index ff1f3e7023..a98644caf2 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -17,7 +17,7 @@ import 'globals.dart'; KernelCompiler get kernelCompiler => context[KernelCompiler]; -typedef void CompilerMessageConsumer(String message); +typedef CompilerMessageConsumer = void Function(String message); class CompilerOutput { final String outputFilename; diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart index 816c77560b..b4b6e6b8d8 100644 --- a/packages/flutter_tools/lib/src/dart/pub.dart +++ b/packages/flutter_tools/lib/src/dart/pub.dart @@ -123,7 +123,7 @@ Future pubGet({ throwToolExit('$directory: pub did not update .packages file (pubspec.yaml file has a newer timestamp)'); } -typedef String MessageFilter(String message); +typedef MessageFilter = String Function(String message); /// Runs pub in 'batch' mode, forwarding complete lines written by pub to its /// stdout/stderr streams to the corresponding stream of this process, optionally diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 7e171d5b3d..695b235083 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -189,7 +189,7 @@ void main() { enum _InitialResult { crashed, timedOut, connected } enum _TestResult { crashed, harnessBailed, testBailed } -typedef Future _Finalizer(); +typedef _Finalizer = Future Function(); class _CompilationRequest { String path; diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index a99c278738..599940d10f 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -22,7 +22,7 @@ import 'globals.dart'; import 'vmservice_record_replay.dart'; /// A function that opens a two-way communication channel to the specified [uri]. -typedef Future> _OpenChannel(Uri uri); +typedef _OpenChannel = Future> Function(Uri uri); _OpenChannel _openChannel = _defaultOpenChannel; @@ -37,13 +37,13 @@ _OpenChannel _openChannel = _defaultOpenChannel; /// hot mode. /// /// See: https://github.com/dart-lang/sdk/issues/30023 -typedef Future ReloadSources( +typedef ReloadSources = Future Function( String isolateId, { bool force, bool pause, }); -typedef Future CompileExpression( +typedef CompileExpression = Future Function( String isolateId, String expression, List definitions, diff --git a/packages/flutter_tools/test/base/flags_test.dart b/packages/flutter_tools/test/base/flags_test.dart index 8f6569037e..99122de197 100644 --- a/packages/flutter_tools/test/base/flags_test.dart +++ b/packages/flutter_tools/test/base/flags_test.dart @@ -11,7 +11,7 @@ import 'package:flutter_tools/src/runner/flutter_command.dart'; import '../src/common.dart'; import '../src/context.dart'; -typedef FutureOr _TestMethod(); +typedef _TestMethod = FutureOr Function(); void main() { Cache.disableLocking(); diff --git a/packages/flutter_tools/test/dart/pub_get_test.dart b/packages/flutter_tools/test/dart/pub_get_test.dart index 373ef1796c..16e23f3a9d 100644 --- a/packages/flutter_tools/test/dart/pub_get_test.dart +++ b/packages/flutter_tools/test/dart/pub_get_test.dart @@ -146,7 +146,7 @@ void main() { }); } -typedef void StartCallback(List command); +typedef StartCallback = void Function(List command); class MockProcessManager implements ProcessManager { MockProcessManager(this.fakeExitCode); diff --git a/packages/flutter_tools/test/ios/cocoapods_test.dart b/packages/flutter_tools/test/ios/cocoapods_test.dart index a39c8d2a22..435bb963ad 100644 --- a/packages/flutter_tools/test/ios/cocoapods_test.dart +++ b/packages/flutter_tools/test/ios/cocoapods_test.dart @@ -18,7 +18,7 @@ import 'package:process/process.dart'; import '../src/common.dart'; import '../src/context.dart'; -typedef Future InvokeProcess(); +typedef InvokeProcess = Future Function(); void main() { FileSystem fs; diff --git a/packages/flutter_tools/test/runner/flutter_command_test.dart b/packages/flutter_tools/test/runner/flutter_command_test.dart index 29ab6df327..2e78161b9d 100644 --- a/packages/flutter_tools/test/runner/flutter_command_test.dart +++ b/packages/flutter_tools/test/runner/flutter_command_test.dart @@ -161,7 +161,7 @@ void main() { } -typedef Future CommandFunction(); +typedef CommandFunction = Future Function(); class DummyFlutterCommand extends FlutterCommand { diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index 0885212de3..743b623884 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart @@ -34,7 +34,7 @@ BufferLogger get testLogger => context[Logger]; MockDeviceManager get testDeviceManager => context[DeviceManager]; MockDoctor get testDoctor => context[Doctor]; -typedef void ContextInitializer(AppContext testContext); +typedef ContextInitializer = void Function(AppContext testContext); @isTest void testUsingContext(String description, dynamic testMethod(), { diff --git a/packages/flutter_tools/test/src/mocks.dart b/packages/flutter_tools/test/src/mocks.dart index 1aab448fc1..408d111b7b 100644 --- a/packages/flutter_tools/test/src/mocks.dart +++ b/packages/flutter_tools/test/src/mocks.dart @@ -109,7 +109,7 @@ ro.build.version.codename=REL } /// A strategy for creating Process objects from a list of commands. -typedef Process ProcessFactory(List command); +typedef ProcessFactory = Process Function(List command); /// A ProcessManager that starts Processes by delegating to a ProcessFactory. class MockProcessManager implements ProcessManager { diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart b/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart index d44c5d6457..1e57368486 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart @@ -43,7 +43,7 @@ enum LoggingLevel { } /// Signature of a function that logs a [LogMessage]. -typedef void LoggingFunction(LogMessage log); +typedef LoggingFunction = void Function(LogMessage log); /// The default logging function. /// diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart index 0156885844..02f22a5026 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart @@ -20,7 +20,7 @@ final Logger _log = Logger('DartVm'); /// Signature of an asynchronous function for astablishing a JSON RPC-2 /// connection to a [Uri]. -typedef Future RpcPeerConnectionFunction(Uri uri); +typedef RpcPeerConnectionFunction = Future Function(Uri uri); /// [DartVm] uses this function to connect to the Dart VM on Fuchsia. /// 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 a99ab506bd..df33bcef0e 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 @@ -30,7 +30,7 @@ final Logger _log = Logger('FuchsiaRemoteConnection'); /// Takes a remote `address`, the target device's port, and an optional /// `interface` and `configFile`. The config file is used primarily for the /// default SSH port forwarding configuration. -typedef Future PortForwardingFunction( +typedef PortForwardingFunction = Future Function( String address, int remotePort, [String interface, String configFile]);