Start using @immutable
annotations (#9152)
There are more places we can use this annotation, but this patch just gets us started.
This commit is contained in:
parent
70536223ee
commit
ea71bdca20
@ -1,7 +1,7 @@
|
||||
name: microbenchmarks
|
||||
description: Small benchmarks for very specific parts of the Flutter framework.
|
||||
dependencies:
|
||||
meta: ^1.0.3
|
||||
meta: ^1.0.5
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_test:
|
||||
|
@ -9,7 +9,7 @@ environment:
|
||||
|
||||
dependencies:
|
||||
args: ^0.13.4
|
||||
meta: ^1.0.4
|
||||
meta: ^1.0.5
|
||||
path: ^1.4.0
|
||||
process: 2.0.3
|
||||
stack_trace: ^1.4.0
|
||||
|
@ -10,6 +10,7 @@
|
||||
library foundation;
|
||||
|
||||
export 'package:meta/meta.dart' show
|
||||
immutable,
|
||||
mustCallSuper,
|
||||
optionalTypeArgs,
|
||||
protected,
|
||||
|
@ -643,8 +643,8 @@ class _MergeableMaterialListBody extends ListBody {
|
||||
this.boxShadows
|
||||
}) : super(children: children, mainAxis: mainAxis);
|
||||
|
||||
List<MergeableMaterialItem> items;
|
||||
List<BoxShadow> boxShadows;
|
||||
final List<MergeableMaterialItem> items;
|
||||
final List<BoxShadow> boxShadows;
|
||||
|
||||
@override
|
||||
RenderListBody createRenderObject(BuildContext context) {
|
||||
|
@ -33,6 +33,7 @@ enum BoxShape {
|
||||
/// An immutable set of radii for each corner of a rectangle.
|
||||
///
|
||||
/// Used by [BoxDecoration] when the shape is a [BoxShape.rectangle].
|
||||
@immutable
|
||||
class BorderRadius {
|
||||
/// Creates a border radius where all radii are [radius].
|
||||
const BorderRadius.all(Radius radius) : this.only(
|
||||
@ -151,6 +152,7 @@ enum BorderStyle {
|
||||
}
|
||||
|
||||
/// A side of a border of a box.
|
||||
@immutable
|
||||
class BorderSide {
|
||||
/// Creates the side of a border.
|
||||
///
|
||||
@ -250,6 +252,7 @@ class BorderSide {
|
||||
}
|
||||
|
||||
/// A border of a box, comprised of four sides.
|
||||
@immutable
|
||||
class Border {
|
||||
/// Creates a border.
|
||||
///
|
||||
@ -502,6 +505,7 @@ class Border {
|
||||
/// (e.g., has a border radius or a circular shape).
|
||||
///
|
||||
/// This class is similar to CSS box-shadow.
|
||||
@immutable
|
||||
class BoxShadow {
|
||||
/// Creates a box shadow.
|
||||
///
|
||||
@ -611,6 +615,7 @@ class BoxShadow {
|
||||
}
|
||||
|
||||
/// A 2D gradient.
|
||||
@immutable
|
||||
abstract class Gradient {
|
||||
/// Abstract const constructor. This constructor enables subclasses to provide
|
||||
/// const constructors so that they can be used in const expressions.
|
||||
@ -963,6 +968,7 @@ void paintImage({
|
||||
///
|
||||
/// The image is painted using [paintImage], which describes the meanings of the
|
||||
/// various fields on this class in more detail.
|
||||
@immutable
|
||||
class BackgroundImage {
|
||||
/// Creates a background image.
|
||||
///
|
||||
|
@ -4,11 +4,14 @@
|
||||
|
||||
import 'dart:ui' show Color, lerpDouble, hashValues;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// A color represented using [alpha], [hue], [saturation], and [value].
|
||||
///
|
||||
/// An [HSVColor] is represented in a parameter space that's motivated by human
|
||||
/// perception. The representation is useful for some color computations (e.g.,
|
||||
/// rotating the hue through the colors of the rainbow).
|
||||
@immutable
|
||||
class HSVColor {
|
||||
/// Creates a color.
|
||||
///
|
||||
|
@ -24,6 +24,7 @@ export 'edge_insets.dart' show EdgeInsets;
|
||||
/// method to obtain a [BoxPainter]. [Decoration] objects can be
|
||||
/// shared between boxes; [BoxPainter] objects can cache resources to
|
||||
/// make painting on a particular surface faster.
|
||||
@immutable
|
||||
abstract class Decoration {
|
||||
/// Abstract const constructor. This constructor enables subclasses to provide
|
||||
/// const constructors so that they can be used in const expressions.
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
import 'dart:ui' as ui show lerpDouble, WindowPadding;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'basic_types.dart';
|
||||
|
||||
/// The two cardinal directions in two dimensions.
|
||||
@ -19,6 +21,7 @@ enum Axis {
|
||||
///
|
||||
/// Typically used for an offset from each of the four sides of a box. For
|
||||
/// example, the padding inside a box can be represented using this class.
|
||||
@immutable
|
||||
class EdgeInsets {
|
||||
/// Creates insets from offsets from the left, top, right, and bottom.
|
||||
const EdgeInsets.fromLTRB(this.left, this.top, this.right, this.bottom);
|
||||
|
@ -4,12 +4,15 @@
|
||||
|
||||
import 'dart:ui' as ui show lerpDouble;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'basic_types.dart';
|
||||
|
||||
/// An offset that's expressed as a fraction of a Size.
|
||||
///
|
||||
/// FractionalOffset(1.0, 0.0) represents the top right of the Size,
|
||||
/// FractionalOffset(0.0, 1.0) represents the bottom left of the Size,
|
||||
@immutable
|
||||
class FractionalOffset {
|
||||
/// Creates a fractional offset.
|
||||
///
|
||||
|
@ -45,6 +45,7 @@ bool _deepEquals(List<Object> a, List<Object> b) {
|
||||
/// * [Text]
|
||||
/// * [RichText]
|
||||
/// * [TextPainter]
|
||||
@immutable
|
||||
class TextSpan {
|
||||
/// Creates a [TextSpan] with the given values.
|
||||
///
|
||||
|
@ -4,9 +4,12 @@
|
||||
|
||||
import 'dart:ui' as ui show ParagraphStyle, TextStyle, lerpDouble;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'basic_types.dart';
|
||||
|
||||
/// An immutable style in which paint text.
|
||||
@immutable
|
||||
class TextStyle {
|
||||
/// Creates a text style.
|
||||
const TextStyle({
|
||||
|
@ -520,6 +520,7 @@ class PaintingContext {
|
||||
///
|
||||
/// * The [toString] method, which should describe the constraints so that they
|
||||
/// appear in a usefully readable form in the output of [debugDumpRenderTree].
|
||||
@immutable
|
||||
abstract class Constraints {
|
||||
/// Abstract const constructor. This constructor enables subclasses to provide
|
||||
/// const constructors so that they can be used in const expressions.
|
||||
|
@ -422,6 +422,7 @@ class SliverConstraints extends Constraints {
|
||||
///
|
||||
/// A sliver can occupy space in several different ways, which is why this class
|
||||
/// contains multiple values.
|
||||
@immutable
|
||||
class SliverGeometry {
|
||||
/// Creates an object that describes the amount of space occupied by a sliver.
|
||||
///
|
||||
|
@ -21,6 +21,7 @@ import 'sliver_multi_box_adaptor.dart';
|
||||
/// to describe the child's placement.
|
||||
/// * [RenderSliverGrid], which uses this class during its
|
||||
/// [RenderSliverGrid.performLayout] method.
|
||||
@immutable
|
||||
class SliverGridGeometry {
|
||||
/// Creates an object that describes the placement of a child in a [RenderSliverGrid].
|
||||
const SliverGridGeometry({
|
||||
@ -99,6 +100,7 @@ class SliverGridGeometry {
|
||||
/// delegates's layout.
|
||||
/// * [RenderSliverGrid], which uses this class during its
|
||||
/// [RenderSliverGrid.performLayout] method.
|
||||
@immutable
|
||||
abstract class SliverGridLayout {
|
||||
/// Abstract const constructor. This constructor enables subclasses to provide
|
||||
/// const constructors so that they can be used in const expressions.
|
||||
|
@ -56,7 +56,7 @@ class Form extends StatefulWidget {
|
||||
///
|
||||
/// If the callback returns a Future that resolves to false, the form's route
|
||||
/// will not be popped.
|
||||
WillPopCallback onWillPop;
|
||||
final WillPopCallback onWillPop;
|
||||
|
||||
@override
|
||||
FormState createState() => new FormState();
|
||||
|
@ -391,6 +391,7 @@ class TypeMatcher<T> {
|
||||
/// be read by descendant widgets.
|
||||
/// * [StatelessWidget], for widgets that always build the same way given a
|
||||
/// particular configuration and ambient state.
|
||||
@immutable
|
||||
abstract class Widget {
|
||||
/// Initializes [key] for subclasses.
|
||||
const Widget({ this.key });
|
||||
|
@ -34,7 +34,7 @@ class WillPopScope extends StatefulWidget {
|
||||
///
|
||||
/// If the callback returns a Future that resolves to false, the enclosing
|
||||
/// route will not be popped.
|
||||
WillPopCallback onWillPop;
|
||||
final WillPopCallback onWillPop;
|
||||
|
||||
@override
|
||||
_WillPopScopeState createState() => new _WillPopScopeState();
|
||||
|
@ -8,7 +8,7 @@ dependencies:
|
||||
collection: '>=1.9.1 <2.0.0'
|
||||
http: '>=0.11.3+12'
|
||||
intl: '>=0.14.0 <0.15.0'
|
||||
meta: ^1.0.4
|
||||
meta: ^1.0.5
|
||||
typed_data: ^1.1.3
|
||||
vector_math: '>=2.0.3 <3.0.0'
|
||||
|
||||
|
@ -31,7 +31,8 @@ class StatefulLeafState extends State<StatefulLeaf> {
|
||||
class KeyedWrapper extends StatelessWidget {
|
||||
KeyedWrapper(this.key1, this.key2);
|
||||
|
||||
Key key1, key2;
|
||||
final Key key1;
|
||||
final Key key2;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -11,7 +11,7 @@ dependencies:
|
||||
file: 2.3.2
|
||||
json_rpc_2: '^2.0.0'
|
||||
matcher: '>=0.12.0 <1.0.0'
|
||||
meta: ^1.0.4
|
||||
meta: ^1.0.5
|
||||
path: '^1.4.0'
|
||||
web_socket_channel: '^1.0.0'
|
||||
vm_service_client: '0.2.2+4'
|
||||
|
@ -19,7 +19,7 @@ dependencies:
|
||||
json_rpc_2: ^2.0.0
|
||||
json_schema: 1.0.6
|
||||
linter: 0.1.30
|
||||
meta: ^1.0.4
|
||||
meta: ^1.0.5
|
||||
mustache: ^0.2.5
|
||||
package_config: '>=0.1.5 <2.0.0'
|
||||
platform: 2.0.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user