From d42dcf2edd906b8bf58e39670d4d18bfb0da49e3 Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Mon, 18 May 2020 11:22:05 +0200 Subject: [PATCH] add @factory to create* methods (#57299) --- packages/flutter/lib/foundation.dart | 1 + packages/flutter/lib/src/gestures/multidrag.dart | 1 + packages/flutter/lib/src/material/ink_well.dart | 1 + packages/flutter/lib/src/painting/decoration.dart | 1 + packages/flutter/lib/src/painting/gradient.dart | 1 + packages/flutter/lib/src/rendering/mouse_cursor.dart | 1 + packages/flutter/lib/src/scheduler/ticker.dart | 1 + packages/flutter/lib/src/widgets/framework.dart | 5 +++++ packages/flutter/lib/src/widgets/navigator.dart | 1 + packages/flutter/lib/src/widgets/routes.dart | 1 + 10 files changed, 14 insertions(+) diff --git a/packages/flutter/lib/foundation.dart b/packages/flutter/lib/foundation.dart index 8a768b9c5f2..65cc88cdc29 100644 --- a/packages/flutter/lib/foundation.dart +++ b/packages/flutter/lib/foundation.dart @@ -10,6 +10,7 @@ library foundation; export 'package:meta/meta.dart' show + factory, immutable, mustCallSuper, nonVirtual, diff --git a/packages/flutter/lib/src/gestures/multidrag.dart b/packages/flutter/lib/src/gestures/multidrag.dart index 5aa735c71ec..a60a8d7508e 100644 --- a/packages/flutter/lib/src/gestures/multidrag.dart +++ b/packages/flutter/lib/src/gestures/multidrag.dart @@ -220,6 +220,7 @@ abstract class MultiDragGestureRecognizer exten /// Subclasses should override this method to create per-pointer state /// objects to track the pointer associated with the given event. @protected + @factory T createNewPointerState(PointerDownEvent event); void _handleEvent(PointerEvent event) { diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index 2f249ac2ca1..2cac56a0c6c 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -159,6 +159,7 @@ abstract class InteractiveInkFeatureFactory { /// /// Subclasses should override this method to return a new instance of an /// [InteractiveInkFeature]. + @factory InteractiveInkFeature create({ @required MaterialInkController controller, @required RenderBox referenceBox, diff --git a/packages/flutter/lib/src/painting/decoration.dart b/packages/flutter/lib/src/painting/decoration.dart index 0c2063b52b5..ae2ae4ec20e 100644 --- a/packages/flutter/lib/src/painting/decoration.dart +++ b/packages/flutter/lib/src/painting/decoration.dart @@ -164,6 +164,7 @@ abstract class Decoration with Diagnosticable { /// The `onChanged` argument configures [BoxPainter.onChanged]. It can be /// omitted if there is no chance that the painter will change (for example, /// if it is a [BoxDecoration] with definitely no [DecorationImage]). + @factory BoxPainter createBoxPainter([ VoidCallback onChanged ]); /// Returns a closed [Path] that describes the outer edge of this decoration. diff --git a/packages/flutter/lib/src/painting/gradient.dart b/packages/flutter/lib/src/painting/gradient.dart index ed2fcc94bab..7f57e8c42b0 100644 --- a/packages/flutter/lib/src/painting/gradient.dart +++ b/packages/flutter/lib/src/painting/gradient.dart @@ -201,6 +201,7 @@ abstract class Gradient { /// /// The shader's transform will be resolved from the [transform] of this /// gradient. + @factory Shader createShader(Rect rect, { TextDirection textDirection }); /// Returns a new gradient with its properties scaled by the given factor. diff --git a/packages/flutter/lib/src/rendering/mouse_cursor.dart b/packages/flutter/lib/src/rendering/mouse_cursor.dart index 094bc9ddf7f..301343dcfa1 100644 --- a/packages/flutter/lib/src/rendering/mouse_cursor.dart +++ b/packages/flutter/lib/src/rendering/mouse_cursor.dart @@ -213,6 +213,7 @@ abstract class MouseCursor with Diagnosticable { /// cursor. A given cursor can be displayed by multiple devices at the same /// time, in which case this method will be called separately for each device. @protected + @factory MouseCursorSession createSession(int device); /// A very short description of the mouse cursor. diff --git a/packages/flutter/lib/src/scheduler/ticker.dart b/packages/flutter/lib/src/scheduler/ticker.dart index 96041984ced..d7dc2c6c7e7 100644 --- a/packages/flutter/lib/src/scheduler/ticker.dart +++ b/packages/flutter/lib/src/scheduler/ticker.dart @@ -35,6 +35,7 @@ abstract class TickerProvider { /// Creates a ticker with the given callback. /// /// The kind of ticker provided depends on the kind of ticker provider. + @factory Ticker createTicker(TickerCallback onTick); } diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index bd212e4481b..7fe0ccfb4d1 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -16,6 +16,7 @@ import 'inherited_model.dart'; export 'dart:ui' show hashValues, hashList; export 'package:flutter/foundation.dart' show + factory, immutable, mustCallSuper, optionalTypeArgs, @@ -488,6 +489,7 @@ abstract class Widget extends DiagnosticableTree { /// widget that is incorporated into the tree multiple times will be inflated /// multiple times. @protected + @factory Element createElement(); /// A short, textual description of this widget. @@ -911,6 +913,7 @@ abstract class StatefulWidget extends Widget { /// again to create a fresh [State] object, simplifying the lifecycle of /// [State] objects. @protected + @factory State createState(); } @@ -1730,6 +1733,7 @@ abstract class RenderObjectWidget extends Widget { /// RenderObjectWidgets always inflate to a [RenderObjectElement] subclass. @override + @factory RenderObjectElement createElement(); /// Creates an instance of the [RenderObject] class that this @@ -1742,6 +1746,7 @@ abstract class RenderObjectWidget extends Widget { /// [createElement] method. See, for example, /// [SingleChildRenderObjectElement.mount]. @protected + @factory RenderObject createRenderObject(BuildContext context); /// Copies the configuration described by this [RenderObjectWidget] to the diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 1ca6f7c2b74..1a39e20e8ef 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -524,6 +524,7 @@ abstract class Page extends RouteSettings { /// Creates the [Route] that corresponds to this page. /// /// The created [Route] must have its [Route.settings] property set to this [Page]. + @factory Route createRoute(BuildContext context); @override diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 3dd804e5c34..76b82bd5f27 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -31,6 +31,7 @@ abstract class OverlayRoute extends Route { }) : super(settings: settings); /// Subclasses should override this getter to return the builders for the overlay. + @factory Iterable createOverlayEntries(); @override