Commit 7be9115a authored by Adam Barth's avatar Adam Barth Committed by GitHub

Deploy `@immutable` in more places (#9462)

Turns out we have many immutable classes.

Fixes #6892
parent 367e11a4
......@@ -52,7 +52,7 @@ class _PointDemoPainter extends CustomPainter {
}) : _repaint = repaint, super(repaint: repaint);
final MaterialPointArcTween arc;
Animation<double> _repaint;
final Animation<double> _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<double> _repaint;
final Animation<double> _repaint;
void drawPoint(Canvas canvas, Offset p, Color color) {
final Paint paint = new Paint()
......
......@@ -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.
......
......@@ -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.
......
......@@ -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].
///
......
......@@ -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.
///
......
......@@ -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.
///
......
......@@ -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.
///
......
......@@ -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.
......
......@@ -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]
/// * <https://material.google.com/components/steppers.html>
@immutable
class Step {
/// Creates a step for a [Stepper].
///
......
......@@ -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.
///
......
......@@ -34,6 +34,7 @@ enum DayPeriod {
}
/// A value representing a time during the day
@immutable
class TimeOfDay {
/// Creates a time of day.
///
......
......@@ -26,6 +26,7 @@ import 'colors.dart';
/// * [Theme]
/// * [ThemeData]
/// * <http://material.google.com/style/typography.html>
@immutable
class TextTheme {
/// Create a text theme that uses the given values.
///
......
......@@ -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].
......
......@@ -529,6 +529,8 @@ class BoxParentData extends ParentData {
abstract class ContainerBoxParentDataMixin<ChildType extends RenderObject> extends BoxParentData with ContainerParentDataMixin<ChildType> { }
enum _IntrinsicDimension { minWidth, maxWidth, minHeight, maxHeight }
@immutable
class _IntrinsicDimensionsCacheEntry {
_IntrinsicDimensionsCacheEntry(this.dimension, this.argument);
......
......@@ -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.
///
......
......@@ -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.
///
......
......@@ -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<RenderBox> {
enum Overflow {
/// Overflowing children will be visible.
visible,
/// Overflowing children will be clipped to the bounds of their parent.
clip,
}
......
......@@ -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.
......
......@@ -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.
///
......
......@@ -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);
......
......@@ -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 });
......
......@@ -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<T> {
/// 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].
///
......
......@@ -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.
///
......
......@@ -28,6 +28,7 @@ abstract class MessageCodec<T> {
}
/// 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].
......
......@@ -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({
......
......@@ -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 });
......
......@@ -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.
///
......
......@@ -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.
///
......
......@@ -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,
......
......@@ -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<T> {
/// Creates an [AsyncSnapshot] with the specified [connectionState],
/// and optionally either [data] or [error] (but not both).
......
......@@ -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<String>] with the given [String].
///
......
......@@ -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.
///
......
......@@ -192,6 +192,7 @@ abstract class Route<T> {
}
/// 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<dynamic> route);
/// ```
///
/// To show a route by name:
///
/// ```dart
/// Navigator.of(context).pushNamed('/b');
/// ```
......@@ -462,6 +464,7 @@ typedef bool RoutePredicate(Route<dynamic> 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,
......
......@@ -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();
......
......@@ -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.
///
......
......@@ -32,6 +32,7 @@ abstract class AbstractScrollState {
void dispatchNotification(Notification notification);
}
@immutable
abstract class ScrollPhysics {
const ScrollPhysics(this.parent);
......
......@@ -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 });
......
......@@ -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';
......
......@@ -36,7 +36,7 @@ List<BoxShadow> getShadow(WidgetTester tester) {
class PaintRecorder extends CustomPainter {
PaintRecorder(this.log);
List<Size> log;
final List<Size> log;
@override
void paint(Canvas canvas, Size size) {
......
......@@ -8,8 +8,8 @@ import 'package:flutter/widgets.dart';
class TestCustomPainter extends CustomPainter {
TestCustomPainter({ this.log, this.name });
List<String> log;
String name;
final List<String> log;
final String name;
@override
void paint(Canvas canvas, Size size) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment