From 7be9115a43d0cf14b2ac7bff7f2bf154a89e0ac8 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Wed, 19 Apr 2017 09:30:43 -0700 Subject: [PATCH] Deploy `@immutable` in more places (#9462) Turns out we have many immutable classes. Fixes #6892 --- dev/manual_tests/material_arc.dart | 4 ++-- packages/flutter/lib/src/animation/curves.dart | 3 +++ packages/flutter/lib/src/gestures/events.dart | 1 + packages/flutter/lib/src/material/data_table.dart | 3 +++ packages/flutter/lib/src/material/icons.dart | 3 +++ packages/flutter/lib/src/material/input_decorator.dart | 1 + packages/flutter/lib/src/material/list_tile.dart | 1 - packages/flutter/lib/src/material/mergeable_material.dart | 1 + packages/flutter/lib/src/material/stepper.dart | 6 ++++++ packages/flutter/lib/src/material/theme_data.dart | 1 + packages/flutter/lib/src/material/time_picker.dart | 1 + packages/flutter/lib/src/material/typography.dart | 1 + packages/flutter/lib/src/painting/box_fit.dart | 3 +++ packages/flutter/lib/src/rendering/box.dart | 2 ++ packages/flutter/lib/src/rendering/editable.dart | 1 + packages/flutter/lib/src/rendering/semantics.dart | 1 + packages/flutter/lib/src/rendering/stack.dart | 2 ++ packages/flutter/lib/src/rendering/table.dart | 3 +++ packages/flutter/lib/src/rendering/view.dart | 2 ++ packages/flutter/lib/src/scheduler/priority.dart | 3 +++ packages/flutter/lib/src/services/clipboard.dart | 3 +++ packages/flutter/lib/src/services/image_provider.dart | 2 ++ packages/flutter/lib/src/services/image_stream.dart | 1 + packages/flutter/lib/src/services/message_codec.dart | 1 + packages/flutter/lib/src/services/raw_keyboard.dart | 2 ++ packages/flutter/lib/src/services/system_chrome.dart | 3 +++ packages/flutter/lib/src/services/text_editing.dart | 2 ++ packages/flutter/lib/src/services/text_input.dart | 2 ++ packages/flutter/lib/src/widgets/animated_cross_fade.dart | 1 + packages/flutter/lib/src/widgets/async.dart | 6 ++++-- packages/flutter/lib/src/widgets/framework.dart | 1 + .../lib/src/widgets/{gridpaper.dart => grid_paper.dart} | 0 packages/flutter/lib/src/widgets/media_query.dart | 1 + packages/flutter/lib/src/widgets/navigator.dart | 3 +++ packages/flutter/lib/src/widgets/scroll_configuration.dart | 1 + packages/flutter/lib/src/widgets/scroll_notification.dart | 1 + packages/flutter/lib/src/widgets/scroll_position.dart | 1 + packages/flutter/lib/src/widgets/table.dart | 1 + packages/flutter/lib/widgets.dart | 2 +- packages/flutter/test/material/material_test.dart | 2 +- packages/flutter/test/widgets/custom_paint_test.dart | 4 ++-- 41 files changed, 74 insertions(+), 9 deletions(-) rename packages/flutter/lib/src/widgets/{gridpaper.dart => grid_paper.dart} (100%) diff --git a/dev/manual_tests/material_arc.dart b/dev/manual_tests/material_arc.dart index 65d915ad1f2..22e6edae8f0 100644 --- a/dev/manual_tests/material_arc.dart +++ b/dev/manual_tests/material_arc.dart @@ -52,7 +52,7 @@ class _PointDemoPainter extends CustomPainter { }) : _repaint = repaint, super(repaint: repaint); final MaterialPointArcTween arc; - Animation _repaint; + final Animation _repaint; void drawPoint(Canvas canvas, Offset point, Color color) { final Paint paint = new Paint() @@ -227,7 +227,7 @@ class _RectangleDemoPainter extends CustomPainter { }) : _repaint = repaint, super(repaint: repaint); final MaterialRectArcTween arc; - Animation _repaint; + final Animation _repaint; void drawPoint(Canvas canvas, Offset p, Color color) { final Paint paint = new Paint() diff --git a/packages/flutter/lib/src/animation/curves.dart b/packages/flutter/lib/src/animation/curves.dart index 0dd99ccc394..7251faf952c 100644 --- a/packages/flutter/lib/src/animation/curves.dart +++ b/packages/flutter/lib/src/animation/curves.dart @@ -4,11 +4,14 @@ import 'dart:math' as math; +import 'package:flutter/foundation.dart'; + /// A mapping of the unit interval to the unit interval. /// /// A curve must map t=0.0 to 0.0 and t=1.0 to 1.0. /// /// See [Curves] for a collection of common animation curves. +@immutable abstract class Curve { /// Abstract const constructor. This constructor enables subclasses to provide /// const constructors so that they can be used in const expressions. diff --git a/packages/flutter/lib/src/gestures/events.dart b/packages/flutter/lib/src/gestures/events.dart index 8c479fc7370..4488d2f0b6c 100644 --- a/packages/flutter/lib/src/gestures/events.dart +++ b/packages/flutter/lib/src/gestures/events.dart @@ -69,6 +69,7 @@ int nthMouseButton(int number) => (kPrimaryMouseButton << (number - 1)) & kMaxUn int nthStylusButton(int number) => (kPrimaryStylusButton << (number - 1)) & kMaxUnsignedSMI; /// Base class for touch, stylus, or mouse events. +@immutable abstract class PointerEvent { /// Abstract const constructor. This constructor enables subclasses to provide /// const constructors so that they can be used in const expressions. diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index f44377fd1c8..40cdad83878 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -30,6 +30,7 @@ typedef void DataColumnSortCallback(int columnIndex, bool ascending); /// One column configuration must be provided for each column to /// display in the table. The list of [DataColumn] objects is passed /// as the `columns` argument to the [new DataTable] constructor. +@immutable class DataColumn { /// Creates the configuration for a column of a [DataTable]. /// @@ -81,6 +82,7 @@ class DataColumn { /// /// The data for this row of the table is provided in the [cells] /// property of the [DataRow] object. +@immutable class DataRow { /// Creates the configuration for a row of a [DataTable]. /// @@ -150,6 +152,7 @@ class DataRow { /// One list of [DataCell] objects must be provided for each [DataRow] /// in the [DataTable], in the [new DataRow] constructor's `cells` /// argument. +@immutable class DataCell { /// Creates an object to hold the data for a cell in a [DataTable]. /// diff --git a/packages/flutter/lib/src/material/icons.dart b/packages/flutter/lib/src/material/icons.dart index a76f5df3c20..9d84275481a 100644 --- a/packages/flutter/lib/src/material/icons.dart +++ b/packages/flutter/lib/src/material/icons.dart @@ -2,9 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/foundation.dart'; + /// A description of a material design icon. /// /// See [Icons] for a number of predefined icons. +@immutable class IconData { /// Creates icon data. /// diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index bf9c5622739..33d8664236b 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -23,6 +23,7 @@ const Curve _kTransitionCurve = Curves.fastOutSlowIn; /// [InputDecoration]. /// * [InputDecorator], which is a widget that draws an [InputDecoration] /// around an arbitrary child widget. +@immutable class InputDecoration { /// Creates a bundle of text and styles used to label an input field. /// diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index bd927281b19..18af24672d4 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -119,7 +119,6 @@ class ListTileTheme extends InheritedWidget { } } - /// A single fixed-height row that typically contains some text as well as /// a leading or trailing icon. /// diff --git a/packages/flutter/lib/src/material/mergeable_material.dart b/packages/flutter/lib/src/material/mergeable_material.dart index 205ceebec6b..132ac83806e 100644 --- a/packages/flutter/lib/src/material/mergeable_material.dart +++ b/packages/flutter/lib/src/material/mergeable_material.dart @@ -11,6 +11,7 @@ import 'package:flutter/rendering.dart'; /// The base type for [MaterialSlice] and [MaterialGap]. /// /// All [MergeableMaterialItem] objects need a [LocalKey]. +@immutable abstract class MergeableMaterialItem { /// Abstract const constructor. This constructor enables subclasses to provide /// const constructors so that they can be used in const expressions. diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index 9d08e8de14e..74a63824e59 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -30,12 +30,16 @@ import 'typography.dart'; enum StepState { /// A step that displays its index in its circle. indexed, + /// A step that displays a pencil icon in its circle. editing, + /// A step that displays a tick icon in its circle. complete, + /// A step that is disabled and does not to react to taps. disabled, + /// A step that is currently having an error. e.g. the use has submitted wrong /// input. error, @@ -45,6 +49,7 @@ enum StepState { enum StepperType { /// A vertical layout of the steps with their content in-between the titles. vertical, + /// A horizontal layout of the steps with their content below the titles. horizontal, } @@ -70,6 +75,7 @@ const double _kTriangleHeight = _kStepSize * 0.866025; // Traingle height. sqrt( /// /// * [Stepper] /// * +@immutable class Step { /// Creates a step for a [Stepper]. /// diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 471f6785e5d..d14f44ae128 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -47,6 +47,7 @@ const Color _kDarkThemeSplashColor = const Color(0x40CCCCCC); /// Use this class to configure a [Theme] widget. /// /// To obtain the current theme, use [Theme.of]. +@immutable class ThemeData { /// Create a ThemeData given a set of preferred values. /// diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index 0367f5c4275..d4269f45c98 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -34,6 +34,7 @@ enum DayPeriod { } /// A value representing a time during the day +@immutable class TimeOfDay { /// Creates a time of day. /// diff --git a/packages/flutter/lib/src/material/typography.dart b/packages/flutter/lib/src/material/typography.dart index 3c0e214ce9c..9ea49c36c69 100644 --- a/packages/flutter/lib/src/material/typography.dart +++ b/packages/flutter/lib/src/material/typography.dart @@ -26,6 +26,7 @@ import 'colors.dart'; /// * [Theme] /// * [ThemeData] /// * +@immutable class TextTheme { /// Create a text theme that uses the given values. /// diff --git a/packages/flutter/lib/src/painting/box_fit.dart b/packages/flutter/lib/src/painting/box_fit.dart index 103798fc436..8ecf0db4e51 100644 --- a/packages/flutter/lib/src/painting/box_fit.dart +++ b/packages/flutter/lib/src/painting/box_fit.dart @@ -4,6 +4,8 @@ import 'dart:math' as math; +import 'package:flutter/foundation.dart'; + import 'basic_types.dart'; /// How a box should be inscribed into another box. @@ -40,6 +42,7 @@ enum BoxFit { } /// The pair of sizes returned by [applyBoxFit]. +@immutable class FittedSizes { /// Creates an object to store a pair of sizes, /// as would be returned by [applyBoxFit]. diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index e10058a0399..1a2cd1c50b5 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -529,6 +529,8 @@ class BoxParentData extends ParentData { abstract class ContainerBoxParentDataMixin extends BoxParentData with ContainerParentDataMixin { } enum _IntrinsicDimension { minWidth, maxWidth, minHeight, maxHeight } + +@immutable class _IntrinsicDimensionsCacheEntry { _IntrinsicDimensionsCacheEntry(this.dimension, this.argument); diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index 32e2a7fc73f..cce290897d1 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -27,6 +27,7 @@ typedef void SelectionChangedHandler(TextSelection selection, RenderEditable ren /// Represents a global screen coordinate of the point in a selection, and the /// text direction at that point. +@immutable class TextSelectionPoint { /// Creates a description of a point in a text selection. /// diff --git a/packages/flutter/lib/src/rendering/semantics.dart b/packages/flutter/lib/src/rendering/semantics.dart index 02e0c639e8f..e0d8b9831b6 100644 --- a/packages/flutter/lib/src/rendering/semantics.dart +++ b/packages/flutter/lib/src/rendering/semantics.dart @@ -55,6 +55,7 @@ typedef bool SemanticsNodeVisitor(SemanticsNode node); /// for the node. /// /// Typically obtained from [SemanticsNode.getSemanticsData]. +@immutable class SemanticsData { /// Creates a semantics data object. /// diff --git a/packages/flutter/lib/src/rendering/stack.dart b/packages/flutter/lib/src/rendering/stack.dart index 9404419e7ad..57c0574ef5c 100644 --- a/packages/flutter/lib/src/rendering/stack.dart +++ b/packages/flutter/lib/src/rendering/stack.dart @@ -19,6 +19,7 @@ import 'object.dart'; /// /// If you create the RelativeRect with null values, the methods on /// RelativeRect will not work usefully (or at all). +@immutable class RelativeRect { /// Creates a RelativeRect with the given values. const RelativeRect.fromLTRB(this.left, this.top, this.right, this.bottom); @@ -204,6 +205,7 @@ class StackParentData extends ContainerBoxParentDataMixin { enum Overflow { /// Overflowing children will be visible. visible, + /// Overflowing children will be clipped to the bounds of their parent. clip, } diff --git a/packages/flutter/lib/src/rendering/table.dart b/packages/flutter/lib/src/rendering/table.dart index 00f64777fe5..a2f0ef742fa 100644 --- a/packages/flutter/lib/src/rendering/table.dart +++ b/packages/flutter/lib/src/rendering/table.dart @@ -5,6 +5,8 @@ import 'dart:collection'; import 'dart:math' as math; +import 'package:flutter/foundation.dart'; + import 'box.dart'; import 'object.dart'; @@ -32,6 +34,7 @@ class TableCellParentData extends BoxParentData { /// distributes the space equally among the flexible columns, /// [FractionColumnWidth], which sizes a column based on the size of the /// table's container. +@immutable abstract class TableColumnWidth { /// Abstract const constructor. This constructor enables subclasses to provide /// const constructors so that they can be used in const expressions. diff --git a/packages/flutter/lib/src/rendering/view.dart b/packages/flutter/lib/src/rendering/view.dart index abdf2303387..cde102755cf 100644 --- a/packages/flutter/lib/src/rendering/view.dart +++ b/packages/flutter/lib/src/rendering/view.dart @@ -6,6 +6,7 @@ import 'dart:developer'; import 'dart:io' show Platform; import 'dart:ui' as ui show Scene, SceneBuilder, window; +import 'package:flutter/foundation.dart'; import 'package:vector_math/vector_math_64.dart'; import 'binding.dart'; @@ -15,6 +16,7 @@ import 'layer.dart'; import 'object.dart'; /// The layout constraints for the root render object. +@immutable class ViewConfiguration { /// Creates a view configuration. /// diff --git a/packages/flutter/lib/src/scheduler/priority.dart b/packages/flutter/lib/src/scheduler/priority.dart index 42bef031575..03adc64aa63 100644 --- a/packages/flutter/lib/src/scheduler/priority.dart +++ b/packages/flutter/lib/src/scheduler/priority.dart @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/foundation.dart'; + /// A task priority, as passed to [SchedulerBinding.scheduleTask]. +@immutable class Priority { const Priority._(this._value); diff --git a/packages/flutter/lib/src/services/clipboard.dart b/packages/flutter/lib/src/services/clipboard.dart index d578e33b849..b91ca9a22cd 100644 --- a/packages/flutter/lib/src/services/clipboard.dart +++ b/packages/flutter/lib/src/services/clipboard.dart @@ -4,12 +4,15 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; + import 'system_channels.dart'; /// Data stored on the system clipboard. /// /// The system clipboard can contain data of various media types. This data /// structure currently supports only plain text data, in the [text] property. +@immutable class ClipboardData { /// Creates data for the system clipboard. const ClipboardData({ this.text }); diff --git a/packages/flutter/lib/src/services/image_provider.dart b/packages/flutter/lib/src/services/image_provider.dart index 61481848454..f6e0d88c33d 100644 --- a/packages/flutter/lib/src/services/image_provider.dart +++ b/packages/flutter/lib/src/services/image_provider.dart @@ -19,6 +19,7 @@ import 'image_stream.dart'; /// Configuration information passed to the [ImageProvider.resolve] method to /// select a specific image. +@immutable class ImageConfiguration { /// Creates an object holding the configuration information for an [ImageProvider]. /// @@ -212,6 +213,7 @@ abstract class ImageProvider { /// Key for the image obtained by an [AssetImage] or [ExactAssetImage]. /// /// This is used to identify the precise resource in the [imageCache]. +@immutable class AssetBundleImageKey { /// Creates the key for an [AssetImage] or [AssetBundleImageProvider]. /// diff --git a/packages/flutter/lib/src/services/image_stream.dart b/packages/flutter/lib/src/services/image_stream.dart index 59ef9ba4483..4f0c8ecfbf6 100644 --- a/packages/flutter/lib/src/services/image_stream.dart +++ b/packages/flutter/lib/src/services/image_stream.dart @@ -11,6 +11,7 @@ import 'package:flutter/foundation.dart'; /// /// ImageInfo objects are used by [ImageStream] objects to represent the /// actual data of the image once it has been obtained. +@immutable class ImageInfo { /// Creates an [ImageInfo] object for the given image and scale. /// diff --git a/packages/flutter/lib/src/services/message_codec.dart b/packages/flutter/lib/src/services/message_codec.dart index af264d40a8e..5b1124a6fb1 100644 --- a/packages/flutter/lib/src/services/message_codec.dart +++ b/packages/flutter/lib/src/services/message_codec.dart @@ -28,6 +28,7 @@ abstract class MessageCodec { } /// An command object representing the invocation of a named method. +@immutable class MethodCall { /// Creates a [MethodCall] representing the invocation of [method] with the /// specified [arguments]. diff --git a/packages/flutter/lib/src/services/raw_keyboard.dart b/packages/flutter/lib/src/services/raw_keyboard.dart index da799a8858f..f77449ac5fc 100644 --- a/packages/flutter/lib/src/services/raw_keyboard.dart +++ b/packages/flutter/lib/src/services/raw_keyboard.dart @@ -20,6 +20,7 @@ import 'system_channels.dart'; /// * [RawKeyEvent] /// * [RawKeyDownEvent] /// * [RawKeyUpEvent] +@immutable abstract class RawKeyEventData { /// Abstract const constructor. This constructor enables subclasses to provide /// const constructors so that they can be used in const expressions. @@ -101,6 +102,7 @@ class RawKeyEventDataFuchsia extends RawKeyEventData { /// * [RawKeyDownEvent] /// * [RawKeyUpEvent] /// * [RawKeyboardListener], a widget that listens for raw key events. +@immutable abstract class RawKeyEvent { /// Initializes fields for subclasses. const RawKeyEvent({ diff --git a/packages/flutter/lib/src/services/system_chrome.dart b/packages/flutter/lib/src/services/system_chrome.dart index 1de0f878908..2d1e04e5015 100644 --- a/packages/flutter/lib/src/services/system_chrome.dart +++ b/packages/flutter/lib/src/services/system_chrome.dart @@ -4,6 +4,8 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; + import 'system_channels.dart'; /// Specifies a particular device orientation. @@ -47,6 +49,7 @@ enum DeviceOrientation { /// interface. /// /// Used by [SystemChrome.setApplicationSwitcherDescription]. +@immutable class ApplicationSwitcherDescription { /// Creates an ApplicationSwitcherDescription. const ApplicationSwitcherDescription({ this.label, this.primaryColor }); diff --git a/packages/flutter/lib/src/services/text_editing.dart b/packages/flutter/lib/src/services/text_editing.dart index 960c92261ce..1247f966338 100644 --- a/packages/flutter/lib/src/services/text_editing.dart +++ b/packages/flutter/lib/src/services/text_editing.dart @@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart'; export 'dart:ui' show TextAffinity, TextPosition; /// A range of characters in a string of text. +@immutable class TextRange { /// Creates a text range. /// @@ -89,6 +90,7 @@ class TextRange { } /// A range of text that represents a selection. +@immutable class TextSelection extends TextRange { /// Creates a text selection. /// diff --git a/packages/flutter/lib/src/services/text_input.dart b/packages/flutter/lib/src/services/text_input.dart index ea5efabbbc4..351aae81766 100644 --- a/packages/flutter/lib/src/services/text_input.dart +++ b/packages/flutter/lib/src/services/text_input.dart @@ -39,6 +39,7 @@ enum TextInputAction { /// See also: /// /// * [TextInput.attach] +@immutable class TextInputConfiguration { /// Creates configuration information for a text input control. /// @@ -74,6 +75,7 @@ TextAffinity _toTextAffinity(String affinity) { } /// The current text, selection, and composing state for editing a run of text. +@immutable class TextEditingValue { /// Creates information for editing a run of text. /// diff --git a/packages/flutter/lib/src/widgets/animated_cross_fade.dart b/packages/flutter/lib/src/widgets/animated_cross_fade.dart index 2867c3aed62..46f8923a0cd 100644 --- a/packages/flutter/lib/src/widgets/animated_cross_fade.dart +++ b/packages/flutter/lib/src/widgets/animated_cross_fade.dart @@ -18,6 +18,7 @@ enum CrossFadeState { /// Show the first child ([AnimatedCrossFade.firstChild]) and hide the second /// ([AnimatedCrossFade.secondChild]]). showFirst, + /// Show the second child ([AnimatedCrossFade.secondChild]) and hide the first /// ([AnimatedCrossFade.firstChild]). showSecond, diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index 8bc039c7fdc..64bf31e1c81 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -8,6 +8,7 @@ import 'dart:async' show Future, Stream, StreamSubscription; +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart' show required; @@ -179,9 +180,10 @@ enum ConnectionState { /// See also: /// /// * [StreamBuilder], which builds itself based on a snapshot from interacting -/// with a [Stream]. +/// with a [Stream]. /// * [FutureBuilder], which builds itself based on a snapshot from interacting -/// with a [Future]. +/// with a [Future]. +@immutable class AsyncSnapshot { /// Creates an [AsyncSnapshot] with the specified [connectionState], /// and optionally either [data] or [error] (but not both). diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index d0702d9acca..b503821147e 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -27,6 +27,7 @@ export 'package:flutter/rendering.dart' show RenderObject, RenderBox, debugDumpR /// Keys must be unique amongst the [Element]s with the same parent. /// /// Subclasses of [Key] should either subclass [LocalKey] or [GlobalKey]. +@immutable abstract class Key { /// Construct a [ValueKey] with the given [String]. /// diff --git a/packages/flutter/lib/src/widgets/gridpaper.dart b/packages/flutter/lib/src/widgets/grid_paper.dart similarity index 100% rename from packages/flutter/lib/src/widgets/gridpaper.dart rename to packages/flutter/lib/src/widgets/grid_paper.dart diff --git a/packages/flutter/lib/src/widgets/media_query.dart b/packages/flutter/lib/src/widgets/media_query.dart index 41bff2d9d88..df53bccf00b 100644 --- a/packages/flutter/lib/src/widgets/media_query.dart +++ b/packages/flutter/lib/src/widgets/media_query.dart @@ -26,6 +26,7 @@ enum Orientation { /// To obtain the current [MediaQueryData] for a given [BuildContext], use the /// [MediaQuery.of] function. For example, to obtain the size of the current /// window, use `MediaQuery.of(context).size`. +@immutable class MediaQueryData { /// Creates data for a media query with explicit values. /// diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 4f4cfea0c5c..ab5430c2be7 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -192,6 +192,7 @@ abstract class Route { } /// Data that might be useful in constructing a [Route]. +@immutable class RouteSettings { /// Creates data used to construct routes. const RouteSettings({ @@ -377,6 +378,7 @@ typedef bool RoutePredicate(Route route); /// ``` /// /// To show a route by name: +/// /// ```dart /// Navigator.of(context).pushNamed('/b'); /// ``` @@ -462,6 +464,7 @@ typedef bool RoutePredicate(Route route); /// } /// )); /// ``` +/// /// The page route is built in two parts, the "page" and the /// "transitions". The page becomes a descendant of the child passed to /// the `buildTransitions` method. Typically the page is only built once, diff --git a/packages/flutter/lib/src/widgets/scroll_configuration.dart b/packages/flutter/lib/src/widgets/scroll_configuration.dart index 2493c2c9a02..21d5846b5f5 100644 --- a/packages/flutter/lib/src/widgets/scroll_configuration.dart +++ b/packages/flutter/lib/src/widgets/scroll_configuration.dart @@ -15,6 +15,7 @@ const Color _kDefaultGlowColor = const Color(0xFFFFFFFF); /// /// Used by [ScrollConfiguration] to configure the [Scrollable] widgets in a /// subtree. +@immutable class ScrollBehavior { /// Creates a description of how [Scrollable] widgets should behave. const ScrollBehavior(); diff --git a/packages/flutter/lib/src/widgets/scroll_notification.dart b/packages/flutter/lib/src/widgets/scroll_notification.dart index 3280694130f..51f0b667bfd 100644 --- a/packages/flutter/lib/src/widgets/scroll_notification.dart +++ b/packages/flutter/lib/src/widgets/scroll_notification.dart @@ -18,6 +18,7 @@ import 'scrollable.dart' show Scrollable, ScrollableState; /// not defined, but must be consistent. For example, they could be in pixels, /// or in percentages, or in units of the [extentInside] (in the latter case, /// [extentInside] would always be 1.0). +@immutable class ScrollMetrics { /// Create a description of the metrics of a [Scrollable]'s contents. /// diff --git a/packages/flutter/lib/src/widgets/scroll_position.dart b/packages/flutter/lib/src/widgets/scroll_position.dart index 1352b70e082..40ea58072b3 100644 --- a/packages/flutter/lib/src/widgets/scroll_position.dart +++ b/packages/flutter/lib/src/widgets/scroll_position.dart @@ -32,6 +32,7 @@ abstract class AbstractScrollState { void dispatchNotification(Notification notification); } +@immutable abstract class ScrollPhysics { const ScrollPhysics(this.parent); diff --git a/packages/flutter/lib/src/widgets/table.dart b/packages/flutter/lib/src/widgets/table.dart index d87aaca500d..505b91b503f 100644 --- a/packages/flutter/lib/src/widgets/table.dart +++ b/packages/flutter/lib/src/widgets/table.dart @@ -28,6 +28,7 @@ export 'package:flutter/rendering.dart' show /// /// The alignment of individual cells in a row can be controlled using a /// [TableCell]. +@immutable class TableRow { /// Creates a row in a [Table]. const TableRow({ this.key, this.decoration, this.children }); diff --git a/packages/flutter/lib/widgets.dart b/packages/flutter/lib/widgets.dart index 6989e549903..0df4bb439e4 100644 --- a/packages/flutter/lib/widgets.dart +++ b/packages/flutter/lib/widgets.dart @@ -26,7 +26,7 @@ export 'src/widgets/focus_scope.dart'; export 'src/widgets/form.dart'; export 'src/widgets/framework.dart'; export 'src/widgets/gesture_detector.dart'; -export 'src/widgets/gridpaper.dart'; +export 'src/widgets/grid_paper.dart'; export 'src/widgets/heroes.dart'; export 'src/widgets/image.dart'; export 'src/widgets/implicit_animations.dart'; diff --git a/packages/flutter/test/material/material_test.dart b/packages/flutter/test/material/material_test.dart index 7fa5dcb901f..1d4dd4a7118 100644 --- a/packages/flutter/test/material/material_test.dart +++ b/packages/flutter/test/material/material_test.dart @@ -36,7 +36,7 @@ List getShadow(WidgetTester tester) { class PaintRecorder extends CustomPainter { PaintRecorder(this.log); - List log; + final List log; @override void paint(Canvas canvas, Size size) { diff --git a/packages/flutter/test/widgets/custom_paint_test.dart b/packages/flutter/test/widgets/custom_paint_test.dart index 3820d7f01a6..18139f10aa8 100644 --- a/packages/flutter/test/widgets/custom_paint_test.dart +++ b/packages/flutter/test/widgets/custom_paint_test.dart @@ -8,8 +8,8 @@ import 'package:flutter/widgets.dart'; class TestCustomPainter extends CustomPainter { TestCustomPainter({ this.log, this.name }); - List log; - String name; + final List log; + final String name; @override void paint(Canvas canvas, Size size) {