Unverified Commit f5a99025 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

enable avoid_equals_and_hash_code_on_mutable_classes (#52507)

parent 80bc3f4a
...@@ -59,7 +59,7 @@ linter: ...@@ -59,7 +59,7 @@ linter:
- avoid_classes_with_only_static_members - avoid_classes_with_only_static_members
# - avoid_double_and_int_checks # only useful when targeting JS runtime # - avoid_double_and_int_checks # only useful when targeting JS runtime
- avoid_empty_else - avoid_empty_else
# - avoid_equals_and_hash_code_on_mutable_classes # not yet tested - avoid_equals_and_hash_code_on_mutable_classes
- avoid_field_initializers_in_const_classes - avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls - avoid_function_literals_in_foreach_calls
# - avoid_implementing_value_types # not yet tested # - avoid_implementing_value_types # not yet tested
......
This diff is collapsed.
...@@ -95,7 +95,7 @@ void main() { ...@@ -95,7 +95,7 @@ void main() {
test('analyze.dart - verifyNoBinaries - positive', () async { test('analyze.dart - verifyNoBinaries - positive', () async {
final String result = await capture(() => verifyNoBinaries( final String result = await capture(() => verifyNoBinaries(
testRootPath, testRootPath,
grandfatheredBinaries: <Hash256>{Hash256(0x39A050CD69434936, 0, 0, 0)}, grandfatheredBinaries: <Hash256>{const Hash256(0x39A050CD69434936, 0, 0, 0)},
), exitCode: Platform.isWindows ? 0 : 1); ), exitCode: Platform.isWindows ? 0 : 1);
if (!Platform.isWindows) { if (!Platform.isWindows) {
// The output starts with the call to git ls-files, the details of which // The output starts with the call to git ls-files, the details of which
...@@ -117,8 +117,8 @@ void main() { ...@@ -117,8 +117,8 @@ void main() {
await capture(() => verifyNoBinaries( await capture(() => verifyNoBinaries(
testRootPath, testRootPath,
grandfatheredBinaries: <Hash256>{ grandfatheredBinaries: <Hash256>{
Hash256(0xA8100AE6AA1940D0, 0xB663BB31CD466142, 0xEBBDBD5187131B92, 0xD93818987832EB89), // sha256("\xff") const Hash256(0xA8100AE6AA1940D0, 0xB663BB31CD466142, 0xEBBDBD5187131B92, 0xD93818987832EB89), // sha256("\xff")
Hash256(0x155644D3F13D98BF, 0, 0, 0), const Hash256(0x155644D3F13D98BF, 0, 0, 0),
}, },
), exitCode: 0); ), exitCode: 0);
}); });
......
...@@ -7,6 +7,7 @@ import 'dart:async'; ...@@ -7,6 +7,7 @@ import 'dart:async';
import 'package:collection/collection.dart' show ListEquality, MapEquality; import 'package:collection/collection.dart' show ListEquality, MapEquality;
import 'package:flutter_devicelab/framework/adb.dart'; import 'package:flutter_devicelab/framework/adb.dart';
import 'package:meta/meta.dart';
import 'common.dart'; import 'common.dart';
...@@ -124,8 +125,9 @@ CommandArgs cmd({ ...@@ -124,8 +125,9 @@ CommandArgs cmd({
typedef ExitErrorFactory = dynamic Function(); typedef ExitErrorFactory = dynamic Function();
@immutable
class CommandArgs { class CommandArgs {
CommandArgs({ this.command, this.arguments, this.environment }); const CommandArgs({ this.command, this.arguments, this.environment });
final String command; final String command;
final List<String> arguments; final List<String> arguments;
......
...@@ -26,6 +26,7 @@ class SectionDetail { ...@@ -26,6 +26,7 @@ class SectionDetail {
final String imageAssetPackage; final String imageAssetPackage;
} }
@immutable
class Section { class Section {
const Section({ const Section({
this.title, this.title,
......
...@@ -12,8 +12,9 @@ import 'demos.dart'; ...@@ -12,8 +12,9 @@ import 'demos.dart';
import 'example_code_parser.dart'; import 'example_code_parser.dart';
import 'syntax_highlighter.dart'; import 'syntax_highlighter.dart';
@immutable
class ComponentDemoTabData { class ComponentDemoTabData {
ComponentDemoTabData({ const ComponentDemoTabData({
this.demoWidget, this.demoWidget,
this.exampleCodeTag, this.exampleCodeTag,
this.description, this.description,
......
...@@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; ...@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import '../demo/all.dart'; import '../demo/all.dart';
import 'icons.dart'; import 'icons.dart';
@immutable
class GalleryDemoCategory { class GalleryDemoCategory {
const GalleryDemoCategory._({ const GalleryDemoCategory._({
@required this.name, @required this.name,
......
...@@ -7,8 +7,9 @@ import 'package:flutter/material.dart'; ...@@ -7,8 +7,9 @@ import 'package:flutter/material.dart';
import 'about.dart'; import 'about.dart';
import 'scales.dart'; import 'scales.dart';
@immutable
class GalleryOptions { class GalleryOptions {
GalleryOptions({ const GalleryOptions({
this.themeMode, this.themeMode,
this.textScaleFactor, this.textScaleFactor,
this.visualDensity, this.visualDensity,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@immutable
class GalleryTextScaleValue { class GalleryTextScaleValue {
const GalleryTextScaleValue(this.scale, this.label); const GalleryTextScaleValue(this.scale, this.label);
...@@ -37,6 +38,7 @@ const List<GalleryTextScaleValue> kAllGalleryTextScaleValues = <GalleryTextScale ...@@ -37,6 +38,7 @@ const List<GalleryTextScaleValue> kAllGalleryTextScaleValues = <GalleryTextScale
GalleryTextScaleValue(2.0, 'Huge'), GalleryTextScaleValue(2.0, 'Huge'),
]; ];
@immutable
class GalleryVisualDensityValue { class GalleryVisualDensityValue {
const GalleryVisualDensityValue(this.visualDensity, this.label); const GalleryVisualDensityValue(this.visualDensity, this.label);
......
...@@ -18,8 +18,9 @@ int sortFilesByPath (FileSystemEntity a, FileSystemEntity b) { ...@@ -18,8 +18,9 @@ int sortFilesByPath (FileSystemEntity a, FileSystemEntity b) {
} }
/// Simple data class to hold parsed locale. Does not promise validity of any data. /// Simple data class to hold parsed locale. Does not promise validity of any data.
@immutable
class LocaleInfo implements Comparable<LocaleInfo> { class LocaleInfo implements Comparable<LocaleInfo> {
LocaleInfo({ const LocaleInfo({
this.languageCode, this.languageCode,
this.scriptCode, this.scriptCode,
this.countryCode, this.countryCode,
......
...@@ -260,6 +260,7 @@ List<Point<double>> parsePoints(String points) { ...@@ -260,6 +260,7 @@ List<Point<double>> parsePoints(String points) {
} }
/// Data for a single animation frame. /// Data for a single animation frame.
@immutable
class FrameData { class FrameData {
const FrameData(this.size, this.paths); const FrameData(this.size, this.paths);
...@@ -285,6 +286,7 @@ class FrameData { ...@@ -285,6 +286,7 @@ class FrameData {
} }
/// Represents an SVG path element. /// Represents an SVG path element.
@immutable
class SvgPath { class SvgPath {
const SvgPath(this.id, this.commands, {this.opacity = 1.0}); const SvgPath(this.id, this.commands, {this.opacity = 1.0});
...@@ -348,6 +350,7 @@ class SvgPath { ...@@ -348,6 +350,7 @@ class SvgPath {
/// * "Z" => SvgPathCommand('Z', []) /// * "Z" => SvgPathCommand('Z', [])
/// * "C 1.0, 1.0 2.0, 2.0 3.0, 3.0" SvgPathCommand('C', [Point(1.0, 1.0), /// * "C 1.0, 1.0 2.0, 2.0 3.0, 3.0" SvgPathCommand('C', [Point(1.0, 1.0),
/// Point(2.0, 2.0), Point(3.0, 3.0)]) /// Point(2.0, 2.0), Point(3.0, 3.0)])
@immutable
class SvgPathCommand { class SvgPathCommand {
const SvgPathCommand(this.type, this.points); const SvgPathCommand(this.type, this.points);
......
...@@ -52,6 +52,7 @@ const Border _kDefaultNavBarBorder = Border( ...@@ -52,6 +52,7 @@ const Border _kDefaultNavBarBorder = Border(
// all transition between each other (per Navigator) via Hero transitions. // all transition between each other (per Navigator) via Hero transitions.
const _HeroTag _defaultHeroTag = _HeroTag(null); const _HeroTag _defaultHeroTag = _HeroTag(null);
@immutable
class _HeroTag { class _HeroTag {
const _HeroTag(this.navigator); const _HeroTag(this.navigator);
......
...@@ -11,6 +11,7 @@ import 'lsq_solver.dart'; ...@@ -11,6 +11,7 @@ import 'lsq_solver.dart';
export 'dart:ui' show Offset; export 'dart:ui' show Offset;
/// A velocity in two dimensions. /// A velocity in two dimensions.
@immutable
class Velocity { class Velocity {
/// Creates a velocity. /// Creates a velocity.
/// ///
......
...@@ -27,6 +27,7 @@ import 'theme.dart'; ...@@ -27,6 +27,7 @@ import 'theme.dart';
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class AppBarTheme with Diagnosticable { class AppBarTheme with Diagnosticable {
/// Creates a theme that can be used for [ThemeData.AppBarTheme]. /// Creates a theme that can be used for [ThemeData.AppBarTheme].
const AppBarTheme({ const AppBarTheme({
......
...@@ -23,6 +23,7 @@ import 'theme.dart'; ...@@ -23,6 +23,7 @@ import 'theme.dart';
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class MaterialBannerThemeData with Diagnosticable { class MaterialBannerThemeData with Diagnosticable {
/// Creates a theme that can be used for [MaterialBannerTheme] or /// Creates a theme that can be used for [MaterialBannerTheme] or
......
...@@ -25,6 +25,7 @@ import 'theme.dart'; ...@@ -25,6 +25,7 @@ import 'theme.dart';
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class BottomAppBarTheme with Diagnosticable { class BottomAppBarTheme with Diagnosticable {
/// Creates a theme that can be used for [ThemeData.BottomAppBarTheme]. /// Creates a theme that can be used for [ThemeData.BottomAppBarTheme].
const BottomAppBarTheme({ const BottomAppBarTheme({
......
...@@ -24,6 +24,7 @@ import 'package:flutter/rendering.dart'; ...@@ -24,6 +24,7 @@ import 'package:flutter/rendering.dart';
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class BottomSheetThemeData with Diagnosticable { class BottomSheetThemeData with Diagnosticable {
/// Creates a theme that can be used for [ThemeData.bottomSheetTheme]. /// Creates a theme that can be used for [ThemeData.bottomSheetTheme].
const BottomSheetThemeData({ const BottomSheetThemeData({
......
...@@ -24,6 +24,7 @@ import 'theme.dart'; ...@@ -24,6 +24,7 @@ import 'theme.dart';
/// its subtree. /// its subtree.
/// * [ButtonBar], which uses this to configure itself and its children /// * [ButtonBar], which uses this to configure itself and its children
/// button widgets. /// button widgets.
@immutable
class ButtonBarThemeData with Diagnosticable { class ButtonBarThemeData with Diagnosticable {
/// Constructs the set of properties used to configure [ButtonBar] widgets. /// Constructs the set of properties used to configure [ButtonBar] widgets.
/// ///
......
...@@ -248,6 +248,7 @@ class ButtonTheme extends InheritedTheme { ...@@ -248,6 +248,7 @@ class ButtonTheme extends InheritedTheme {
/// A button theme can be specified as part of the overall Material theme /// A button theme can be specified as part of the overall Material theme
/// using [ThemeData.buttonTheme]. The Material theme's button theme data /// using [ThemeData.buttonTheme]. The Material theme's button theme data
/// can be overridden with [ButtonTheme]. /// can be overridden with [ButtonTheme].
@immutable
class ButtonThemeData with Diagnosticable { class ButtonThemeData with Diagnosticable {
/// Create a button theme object that can be used with [ButtonTheme] /// Create a button theme object that can be used with [ButtonTheme]
/// or [ThemeData]. /// or [ThemeData].
......
...@@ -26,6 +26,7 @@ import 'theme.dart'; ...@@ -26,6 +26,7 @@ import 'theme.dart';
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class CardTheme with Diagnosticable { class CardTheme with Diagnosticable {
/// Creates a theme that can be used for [ThemeData.cardTheme]. /// Creates a theme that can be used for [ThemeData.cardTheme].
......
...@@ -2157,6 +2157,7 @@ class _RenderChipElement extends RenderObjectElement { ...@@ -2157,6 +2157,7 @@ class _RenderChipElement extends RenderObjectElement {
} }
} }
@immutable
class _ChipRenderTheme { class _ChipRenderTheme {
const _ChipRenderTheme({ const _ChipRenderTheme({
@required this.avatar, @required this.avatar,
......
...@@ -168,6 +168,7 @@ class ChipTheme extends InheritedTheme { ...@@ -168,6 +168,7 @@ class ChipTheme extends InheritedTheme {
/// * [Theme] widget, which performs a similar function to [ChipTheme], /// * [Theme] widget, which performs a similar function to [ChipTheme],
/// but for overall themes. /// but for overall themes.
/// * [ThemeData], which has a default [ChipThemeData]. /// * [ThemeData], which has a default [ChipThemeData].
@immutable
class ChipThemeData with Diagnosticable { class ChipThemeData with Diagnosticable {
/// Create a [ChipThemeData] given a set of exact values. All the values /// Create a [ChipThemeData] given a set of exact values. All the values
/// must be specified except for [shadowColor], [selectedShadowColor], /// must be specified except for [shadowColor], [selectedShadowColor],
......
...@@ -27,6 +27,7 @@ import 'theme.dart'; ...@@ -27,6 +27,7 @@ import 'theme.dart';
/// * [Dialog], a material dialog that can be customized using this [DialogTheme]. /// * [Dialog], a material dialog that can be customized using this [DialogTheme].
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class DialogTheme with Diagnosticable { class DialogTheme with Diagnosticable {
/// Creates a dialog theme that can be used for [ThemeData.dialogTheme]. /// Creates a dialog theme that can be used for [ThemeData.dialogTheme].
const DialogTheme({ const DialogTheme({
......
...@@ -26,6 +26,7 @@ import 'theme.dart'; ...@@ -26,6 +26,7 @@ import 'theme.dart';
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class DividerThemeData with Diagnosticable { class DividerThemeData with Diagnosticable {
/// Creates a theme that can be used for [DividerTheme] or /// Creates a theme that can be used for [DividerTheme] or
......
...@@ -368,6 +368,7 @@ class _DropdownMenuRouteLayout<T> extends SingleChildLayoutDelegate { ...@@ -368,6 +368,7 @@ class _DropdownMenuRouteLayout<T> extends SingleChildLayoutDelegate {
// We box the return value so that the return value can be null. Otherwise, // We box the return value so that the return value can be null. Otherwise,
// canceling the route (which returns null) would get confused with actually // canceling the route (which returns null) would get confused with actually
// returning a real null value. // returning a real null value.
@immutable
class _DropdownRouteResult<T> { class _DropdownRouteResult<T> {
const _DropdownRouteResult(this.result); const _DropdownRouteResult(this.result);
......
...@@ -26,6 +26,7 @@ import 'package:flutter/rendering.dart'; ...@@ -26,6 +26,7 @@ import 'package:flutter/rendering.dart';
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class FloatingActionButtonThemeData with Diagnosticable { class FloatingActionButtonThemeData with Diagnosticable {
/// Creates a theme that can be used for /// Creates a theme that can be used for
/// [ThemeData.floatingActionButtonTheme]. /// [ThemeData.floatingActionButtonTheme].
......
...@@ -40,6 +40,7 @@ class _InputBorderGap extends ChangeNotifier { ...@@ -40,6 +40,7 @@ class _InputBorderGap extends ChangeNotifier {
} }
@override @override
// ignore: avoid_equals_and_hash_code_on_mutable_classes, this class is not used in collection
bool operator ==(Object other) { bool operator ==(Object other) {
if (identical(this, other)) if (identical(this, other))
return true; return true;
...@@ -51,6 +52,7 @@ class _InputBorderGap extends ChangeNotifier { ...@@ -51,6 +52,7 @@ class _InputBorderGap extends ChangeNotifier {
} }
@override @override
// ignore: avoid_equals_and_hash_code_on_mutable_classes, this class is not used in collection
int get hashCode => hashValues(start, extent); int get hashCode => hashValues(start, extent);
} }
...@@ -489,6 +491,7 @@ enum _DecorationSlot { ...@@ -489,6 +491,7 @@ enum _DecorationSlot {
} }
// An analog of InputDecoration for the _Decorator widget. // An analog of InputDecoration for the _Decorator widget.
@immutable
class _Decoration { class _Decoration {
const _Decoration({ const _Decoration({
@required this.contentPadding, @required this.contentPadding,
......
...@@ -33,6 +33,7 @@ import 'theme_data.dart'; ...@@ -33,6 +33,7 @@ import 'theme_data.dart';
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class NavigationRailThemeData with Diagnosticable { class NavigationRailThemeData with Diagnosticable {
/// Creates a theme that can be used for [ThemeData.navigationRailTheme]. /// Creates a theme that can be used for [ThemeData.navigationRailTheme].
const NavigationRailThemeData({ const NavigationRailThemeData({
......
...@@ -29,6 +29,7 @@ import 'theme.dart'; ...@@ -29,6 +29,7 @@ import 'theme.dart';
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class PopupMenuThemeData with Diagnosticable { class PopupMenuThemeData with Diagnosticable {
/// Creates the set of properties used to configure [PopupMenuTheme]. /// Creates the set of properties used to configure [PopupMenuTheme].
const PopupMenuThemeData({ const PopupMenuThemeData({
......
...@@ -305,6 +305,7 @@ enum Thumb { ...@@ -305,6 +305,7 @@ enum Thumb {
/// {@macro flutter.material.slider.seeAlso.rangeSliderValueIndicatorShape} /// {@macro flutter.material.slider.seeAlso.rangeSliderValueIndicatorShape}
/// {@macro flutter.material.slider.seeAlso.rangeSliderTrackShape} /// {@macro flutter.material.slider.seeAlso.rangeSliderTrackShape}
/// {@macro flutter.material.slider.seeAlso.rangeSliderTickMarkShape} /// {@macro flutter.material.slider.seeAlso.rangeSliderTickMarkShape}
@immutable
class SliderThemeData with Diagnosticable { class SliderThemeData with Diagnosticable {
/// Create a [SliderThemeData] given a set of exact values. All the values /// Create a [SliderThemeData] given a set of exact values. All the values
/// must be specified. /// must be specified.
...@@ -2866,6 +2867,7 @@ typedef RangeThumbSelector = Thumb Function( ...@@ -2866,6 +2867,7 @@ typedef RangeThumbSelector = Thumb Function(
/// This object is passed into [RangeSlider.values] to set its values, and it /// This object is passed into [RangeSlider.values] to set its values, and it
/// is emitted in [RangeSlider.onChange], [RangeSlider.onChangeStart], and /// is emitted in [RangeSlider.onChange], [RangeSlider.onChangeStart], and
/// [RangeSlider.onChangeEnd] when the values change. /// [RangeSlider.onChangeEnd] when the values change.
@immutable
class RangeValues { class RangeValues {
/// Creates pair of start and end values. /// Creates pair of start and end values.
const RangeValues(this.start, this.end); const RangeValues(this.start, this.end);
...@@ -2905,6 +2907,7 @@ class RangeValues { ...@@ -2905,6 +2907,7 @@ class RangeValues {
/// ///
/// Used in combination with [RangeSlider.showValueIndicator] to display /// Used in combination with [RangeSlider.showValueIndicator] to display
/// labels above the thumbs. /// labels above the thumbs.
@immutable
class RangeLabels { class RangeLabels {
/// Creates pair of start and end labels. /// Creates pair of start and end labels.
const RangeLabels(this.start, this.end); const RangeLabels(this.start, this.end);
......
...@@ -46,6 +46,7 @@ enum SnackBarBehavior { ...@@ -46,6 +46,7 @@ enum SnackBarBehavior {
/// ///
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class SnackBarThemeData with Diagnosticable { class SnackBarThemeData with Diagnosticable {
/// Creates a theme that can be used for [ThemeData.snackBarTheme]. /// Creates a theme that can be used for [ThemeData.snackBarTheme].
......
...@@ -23,6 +23,7 @@ import 'theme.dart'; ...@@ -23,6 +23,7 @@ import 'theme.dart';
/// * [TabBar], a widget that displays a horizontal row of tabs. /// * [TabBar], a widget that displays a horizontal row of tabs.
/// * [ThemeData], which describes the overall theme information for the /// * [ThemeData], which describes the overall theme information for the
/// application. /// application.
@immutable
class TabBarTheme with Diagnosticable { class TabBarTheme with Diagnosticable {
/// Creates a tab bar theme that can be used with [ThemeData.tabBarTheme]. /// Creates a tab bar theme that can be used with [ThemeData.tabBarTheme].
const TabBarTheme({ const TabBarTheme({
......
...@@ -1636,8 +1636,9 @@ class MaterialBasedCupertinoThemeData extends CupertinoThemeData { ...@@ -1636,8 +1636,9 @@ class MaterialBasedCupertinoThemeData extends CupertinoThemeData {
} }
} }
@immutable
class _IdentityThemeDataCacheKey { class _IdentityThemeDataCacheKey {
_IdentityThemeDataCacheKey(this.baseTheme, this.localTextGeometry); const _IdentityThemeDataCacheKey(this.baseTheme, this.localTextGeometry);
final ThemeData baseTheme; final ThemeData baseTheme;
final TextTheme localTextGeometry; final TextTheme localTextGeometry;
...@@ -1713,6 +1714,7 @@ class _FifoCache<K, V> { ...@@ -1713,6 +1714,7 @@ class _FifoCache<K, V> {
/// * [ThemeData.visualDensity], where this property is used to specify the base /// * [ThemeData.visualDensity], where this property is used to specify the base
/// horizontal density of Material components. /// horizontal density of Material components.
/// * [Material design guidance on density](https://material.io/design/layout/applying-density.html). /// * [Material design guidance on density](https://material.io/design/layout/applying-density.html).
@immutable
class VisualDensity with Diagnosticable { class VisualDensity with Diagnosticable {
/// A const constructor for [VisualDensity]. /// A const constructor for [VisualDensity].
/// ///
......
...@@ -24,6 +24,7 @@ import 'theme.dart'; ...@@ -24,6 +24,7 @@ import 'theme.dart';
/// ///
/// * [ToggleButtonsTheme], which describes the actual configuration of a /// * [ToggleButtonsTheme], which describes the actual configuration of a
/// toggle buttons theme. /// toggle buttons theme.
@immutable
class ToggleButtonsThemeData with Diagnosticable { class ToggleButtonsThemeData with Diagnosticable {
/// Creates the set of color and border properties used to configure /// Creates the set of color and border properties used to configure
/// [ToggleButtons]. /// [ToggleButtons].
......
...@@ -23,6 +23,7 @@ import 'theme.dart'; ...@@ -23,6 +23,7 @@ import 'theme.dart';
/// subtree. /// subtree.
/// * [TooltipThemeData], which describes the actual configuration of a /// * [TooltipThemeData], which describes the actual configuration of a
/// tooltip theme. /// tooltip theme.
@immutable
class TooltipThemeData with Diagnosticable { class TooltipThemeData with Diagnosticable {
/// Creates the set of properties used to configure [Tooltip]s. /// Creates the set of properties used to configure [Tooltip]s.
const TooltipThemeData({ const TooltipThemeData({
......
...@@ -15,6 +15,7 @@ import 'image_provider.dart' as image_provider; ...@@ -15,6 +15,7 @@ import 'image_provider.dart' as image_provider;
import 'image_stream.dart'; import 'image_stream.dart';
/// The dart:io implementation of [image_provider.NetworkImage]. /// The dart:io implementation of [image_provider.NetworkImage].
@immutable
class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkImage> implements image_provider.NetworkImage { class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkImage> implements image_provider.NetworkImage {
/// Creates an object that fetches the image at the given URL. /// Creates an object that fetches the image at the given URL.
/// ///
......
...@@ -13,6 +13,7 @@ import 'image_stream.dart'; ...@@ -13,6 +13,7 @@ import 'image_stream.dart';
/// The dart:html implementation of [image_provider.NetworkImage]. /// The dart:html implementation of [image_provider.NetworkImage].
/// ///
/// NetworkImage on the web does not support decoding to a specified size. /// NetworkImage on the web does not support decoding to a specified size.
@immutable
class NetworkImage class NetworkImage
extends image_provider.ImageProvider<image_provider.NetworkImage> extends image_provider.ImageProvider<image_provider.NetworkImage>
implements image_provider.NetworkImage { implements image_provider.NetworkImage {
......
...@@ -425,6 +425,7 @@ class HSLColor { ...@@ -425,6 +425,7 @@ class HSLColor {
/// primary and accent color swatches. /// primary and accent color swatches.
/// * [material.Colors], which defines all of the standard material design /// * [material.Colors], which defines all of the standard material design
/// colors. /// colors.
@immutable
class ColorSwatch<T> extends Color { class ColorSwatch<T> extends Color {
/// Creates a color that has a small table of related colors called a "swatch". /// Creates a color that has a small table of related colors called a "swatch".
/// ///
......
...@@ -530,6 +530,7 @@ class ImageCache { ...@@ -530,6 +530,7 @@ class ImageCache {
/// ///
/// To obtain an [ImageCacheStatus], use [ImageCache.statusForKey] or /// To obtain an [ImageCacheStatus], use [ImageCache.statusForKey] or
/// [ImageProvider.obtainCacheStatus]. /// [ImageProvider.obtainCacheStatus].
@immutable
class ImageCacheStatus { class ImageCacheStatus {
const ImageCacheStatus._({ const ImageCacheStatus._({
this.pending = false, this.pending = false,
......
...@@ -674,6 +674,7 @@ abstract class AssetBundleImageProvider extends ImageProvider<AssetBundleImageKe ...@@ -674,6 +674,7 @@ abstract class AssetBundleImageProvider extends ImageProvider<AssetBundleImageKe
} }
} }
@immutable
class _SizeAwareCacheKey { class _SizeAwareCacheKey {
const _SizeAwareCacheKey(this.providerCacheKey, this.width, this.height); const _SizeAwareCacheKey(this.providerCacheKey, this.width, this.height);
...@@ -818,6 +819,7 @@ abstract class NetworkImage extends ImageProvider<NetworkImage> { ...@@ -818,6 +819,7 @@ abstract class NetworkImage extends ImageProvider<NetworkImage> {
/// See also: /// See also:
/// ///
/// * [Image.file] for a shorthand of an [Image] widget backed by [FileImage]. /// * [Image.file] for a shorthand of an [Image] widget backed by [FileImage].
@immutable
class FileImage extends ImageProvider<FileImage> { class FileImage extends ImageProvider<FileImage> {
/// Creates an object that decodes a [File] as an image. /// Creates an object that decodes a [File] as an image.
/// ///
...@@ -890,6 +892,7 @@ class FileImage extends ImageProvider<FileImage> { ...@@ -890,6 +892,7 @@ class FileImage extends ImageProvider<FileImage> {
/// See also: /// See also:
/// ///
/// * [Image.memory] for a shorthand of an [Image] widget backed by [MemoryImage]. /// * [Image.memory] for a shorthand of an [Image] widget backed by [MemoryImage].
@immutable
class MemoryImage extends ImageProvider<MemoryImage> { class MemoryImage extends ImageProvider<MemoryImage> {
/// Creates an object that decodes a [Uint8List] buffer as an image. /// Creates an object that decodes a [Uint8List] buffer as an image.
/// ///
...@@ -1008,6 +1011,7 @@ class MemoryImage extends ImageProvider<MemoryImage> { ...@@ -1008,6 +1011,7 @@ class MemoryImage extends ImageProvider<MemoryImage> {
/// ///
/// * [Image.asset] for a shorthand of an [Image] widget backed by /// * [Image.asset] for a shorthand of an [Image] widget backed by
/// [ExactAssetImage] when using a scale. /// [ExactAssetImage] when using a scale.
@immutable
class ExactAssetImage extends AssetBundleImageProvider { class ExactAssetImage extends AssetBundleImageProvider {
/// Creates an object that fetches the given image from an asset bundle. /// Creates an object that fetches the given image from an asset bundle.
/// ///
......
...@@ -120,6 +120,7 @@ const String _kAssetManifestFileName = 'AssetManifest.json'; ...@@ -120,6 +120,7 @@ const String _kAssetManifestFileName = 'AssetManifest.json';
/// ///
/// * [Image.asset] for a shorthand of an [Image] widget backed by [AssetImage] /// * [Image.asset] for a shorthand of an [Image] widget backed by [AssetImage]
/// when used without a scale. /// when used without a scale.
@immutable
class AssetImage extends AssetBundleImageProvider { class AssetImage extends AssetBundleImageProvider {
/// Creates an object that fetches an image from an asset bundle. /// Creates an object that fetches an image from an asset bundle.
/// ///
......
...@@ -121,6 +121,7 @@ abstract class KeyboardKey with Diagnosticable { ...@@ -121,6 +121,7 @@ abstract class KeyboardKey with Diagnosticable {
/// to keyboard events. /// to keyboard events.
/// * [RawKeyboardListener], a widget used to listen to and supply handlers for /// * [RawKeyboardListener], a widget used to listen to and supply handlers for
/// keyboard events. /// keyboard events.
@immutable
class LogicalKeyboardKey extends KeyboardKey { class LogicalKeyboardKey extends KeyboardKey {
/// Creates a LogicalKeyboardKey object with an optional key label and debug /// Creates a LogicalKeyboardKey object with an optional key label and debug
/// name. /// name.
...@@ -2043,6 +2044,7 @@ class LogicalKeyboardKey extends KeyboardKey { ...@@ -2043,6 +2044,7 @@ class LogicalKeyboardKey extends KeyboardKey {
/// to keyboard events. /// to keyboard events.
/// * [RawKeyboardListener], a widget used to listen to and supply handlers for /// * [RawKeyboardListener], a widget used to listen to and supply handlers for
/// keyboard events. /// keyboard events.
@immutable
class PhysicalKeyboardKey extends KeyboardKey { class PhysicalKeyboardKey extends KeyboardKey {
/// Creates a PhysicalKeyboardKey object with an optional debug name. /// Creates a PhysicalKeyboardKey object with an optional debug name.
/// ///
......
...@@ -623,6 +623,7 @@ class RawKeyboard { ...@@ -623,6 +623,7 @@ class RawKeyboard {
void clearKeysPressed() => _keysPressed.clear(); void clearKeysPressed() => _keysPressed.clear();
} }
@immutable
class _ModifierSidePair extends Object { class _ModifierSidePair extends Object {
const _ModifierSidePair(this.modifier, this.side); const _ModifierSidePair(this.modifier, this.side);
......
...@@ -83,6 +83,7 @@ enum SystemUiOverlay { ...@@ -83,6 +83,7 @@ enum SystemUiOverlay {
/// Specifies a preference for the style of the system overlays. /// Specifies a preference for the style of the system overlays.
/// ///
/// Used by [SystemChrome.setSystemUIOverlayStyle]. /// Used by [SystemChrome.setSystemUIOverlayStyle].
@immutable
class SystemUiOverlayStyle { class SystemUiOverlayStyle {
/// Creates a new [SystemUiOverlayStyle]. /// Creates a new [SystemUiOverlayStyle].
const SystemUiOverlayStyle({ const SystemUiOverlayStyle({
......
...@@ -82,6 +82,7 @@ enum SmartQuotesType { ...@@ -82,6 +82,7 @@ enum SmartQuotesType {
/// This class stays as close to [Enum] interface as possible, and allows /// This class stays as close to [Enum] interface as possible, and allows
/// for additional flags for some input types. For example, numeric input /// for additional flags for some input types. For example, numeric input
/// can specify whether it supports decimal numbers and/or signed numbers. /// can specify whether it supports decimal numbers and/or signed numbers.
@immutable
class TextInputType { class TextInputType {
const TextInputType._(this.index) const TextInputType._(this.index)
: signed = null, : signed = null,
......
...@@ -2887,7 +2887,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ...@@ -2887,7 +2887,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
// Custom implementation of `operator ==` optimized for the ".of" pattern // Custom implementation of `operator ==` optimized for the ".of" pattern
// used with `InheritedWidgets`. // used with `InheritedWidgets`.
@nonVirtual
@override @override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
bool operator ==(Object other) => identical(this, other); bool operator ==(Object other) => identical(this, other);
// Custom implementation of hash code optimized for the ".of" pattern used // Custom implementation of hash code optimized for the ".of" pattern used
...@@ -2904,7 +2906,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ...@@ -2904,7 +2906,9 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
// //
// * https://dart.dev/articles/dart-vm/numeric-computation, which // * https://dart.dev/articles/dart-vm/numeric-computation, which
// explains how numbers are represented in Dart. // explains how numbers are represented in Dart.
@nonVirtual
@override @override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode => _cachedHash; int get hashCode => _cachedHash;
final int _cachedHash = _nextHashCode = (_nextHashCode + 1) % 0xffffff; final int _cachedHash = _nextHashCode = (_nextHashCode + 1) % 0xffffff;
static int _nextHashCode = 1; static int _nextHashCode = 1;
......
...@@ -18,6 +18,7 @@ import 'framework.dart' show BuildContext; ...@@ -18,6 +18,7 @@ import 'framework.dart' show BuildContext;
/// To obtain the current icon theme, use [IconTheme.of]. To convert an icon /// To obtain the current icon theme, use [IconTheme.of]. To convert an icon
/// theme to a version with all the fields filled in, use [new /// theme to a version with all the fields filled in, use [new
/// IconThemeData.fallback]. /// IconThemeData.fallback].
@immutable
class IconThemeData with Diagnosticable { class IconThemeData with Diagnosticable {
/// Creates an icon theme data. /// Creates an icon theme data.
/// ///
......
...@@ -38,8 +38,9 @@ class PageStorageKey<T> extends ValueKey<T> { ...@@ -38,8 +38,9 @@ class PageStorageKey<T> extends ValueKey<T> {
const PageStorageKey(T value) : super(value); const PageStorageKey(T value) : super(value);
} }
@immutable
class _StorageEntryIdentifier { class _StorageEntryIdentifier {
_StorageEntryIdentifier(this.keys) const _StorageEntryIdentifier(this.keys)
: assert(keys != null); : assert(keys != null);
final List<PageStorageKey<dynamic>> keys; final List<PageStorageKey<dynamic>> keys;
......
...@@ -82,6 +82,7 @@ class KeySet<T extends KeyboardKey> { ...@@ -82,6 +82,7 @@ class KeySet<T extends KeyboardKey> {
final HashSet<T> _keys; final HashSet<T> _keys;
@override @override
// ignore: avoid_equals_and_hash_code_on_mutable_classes, to remove in NNBD with a late final hashcode
bool operator ==(Object other) { bool operator ==(Object other) {
if (other.runtimeType != runtimeType) { if (other.runtimeType != runtimeType) {
return false; return false;
...@@ -99,6 +100,7 @@ class KeySet<T extends KeyboardKey> { ...@@ -99,6 +100,7 @@ class KeySet<T extends KeyboardKey> {
int _hashCode; int _hashCode;
@override @override
// ignore: avoid_equals_and_hash_code_on_mutable_classes, to remove in NNBD with a late final hashcode
int get hashCode { int get hashCode {
// Return cached hash code if available. // Return cached hash code if available.
if (_hashCode != null) { if (_hashCode != null) {
......
...@@ -2426,6 +2426,7 @@ class _RenderInspectorOverlay extends RenderBox { ...@@ -2426,6 +2426,7 @@ class _RenderInspectorOverlay extends RenderBox {
} }
} }
@immutable
class _TransformedRect { class _TransformedRect {
_TransformedRect(RenderObject object) _TransformedRect(RenderObject object)
: rect = object.semanticBounds, : rect = object.semanticBounds,
...@@ -2451,8 +2452,9 @@ class _TransformedRect { ...@@ -2451,8 +2452,9 @@ class _TransformedRect {
/// ///
/// The equality operator can be used to determine whether the overlay needs to /// The equality operator can be used to determine whether the overlay needs to
/// be rendered again. /// be rendered again.
@immutable
class _InspectorOverlayRenderState { class _InspectorOverlayRenderState {
_InspectorOverlayRenderState({ const _InspectorOverlayRenderState({
@required this.overlayRect, @required this.overlayRect,
@required this.selected, @required this.selected,
@required this.candidates, @required this.candidates,
......
...@@ -553,7 +553,7 @@ Future<Size> _resolveAndGetSize(ImageProvider imageProvider, ...@@ -553,7 +553,7 @@ Future<Size> _resolveAndGetSize(ImageProvider imageProvider,
// This version of MemoryImage guarantees obtainKey returns a future that has not been // This version of MemoryImage guarantees obtainKey returns a future that has not been
// completed synchronously. // completed synchronously.
class AsyncKeyMemoryImage extends MemoryImage { class AsyncKeyMemoryImage extends MemoryImage {
AsyncKeyMemoryImage(Uint8List bytes) : super(bytes); const AsyncKeyMemoryImage(Uint8List bytes) : super(bytes);
@override @override
Future<MemoryImage> obtainKey(ImageConfiguration configuration) { Future<MemoryImage> obtainKey(ImageConfiguration configuration) {
......
...@@ -157,7 +157,7 @@ class FakeAndroidPlatformViewsController { ...@@ -157,7 +157,7 @@ class FakeAndroidPlatformViewsController {
if (resizeCompleter != null) { if (resizeCompleter != null) {
await resizeCompleter.future; await resizeCompleter.future;
} }
_views[id].size = Size(width, height); _views[id] = _views[id].copyWith(size: Size(width, height));
return Future<dynamic>.sync(() => null); return Future<dynamic>.sync(() => null);
} }
...@@ -195,7 +195,7 @@ class FakeAndroidPlatformViewsController { ...@@ -195,7 +195,7 @@ class FakeAndroidPlatformViewsController {
message: 'Trying to resize a platform view with unknown id: $id', message: 'Trying to resize a platform view with unknown id: $id',
); );
_views[id].layoutDirection = layoutDirection; _views[id] = _views[id].copyWith(layoutDirection: layoutDirection);
return Future<dynamic>.sync(() => null); return Future<dynamic>.sync(() => null);
} }
...@@ -377,14 +377,23 @@ class FakeHtmlPlatformViewsController { ...@@ -377,14 +377,23 @@ class FakeHtmlPlatformViewsController {
} }
} }
@immutable
class FakeAndroidPlatformView { class FakeAndroidPlatformView {
FakeAndroidPlatformView(this.id, this.type, this.size, this.layoutDirection, [this.creationParams]); const FakeAndroidPlatformView(this.id, this.type, this.size, this.layoutDirection, [this.creationParams]);
final int id; final int id;
final String type; final String type;
final Uint8List creationParams; final Uint8List creationParams;
Size size; final Size size;
int layoutDirection; final int layoutDirection;
FakeAndroidPlatformView copyWith({Size size, int layoutDirection}) => FakeAndroidPlatformView(
id,
type,
size ?? this.size,
layoutDirection ?? this.layoutDirection,
creationParams,
);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
...@@ -393,12 +402,13 @@ class FakeAndroidPlatformView { ...@@ -393,12 +402,13 @@ class FakeAndroidPlatformView {
return other is FakeAndroidPlatformView return other is FakeAndroidPlatformView
&& other.id == id && other.id == id
&& other.type == type && other.type == type
&& other.creationParams == creationParams && listEquals<int>(other.creationParams, creationParams)
&& other.size == size; && other.size == size
&& other.layoutDirection == layoutDirection;
} }
@override @override
int get hashCode => hashValues(id, type, size, layoutDirection); int get hashCode => hashValues(id, type, hashList(creationParams), size, layoutDirection);
@override @override
String toString() { String toString() {
...@@ -406,6 +416,7 @@ class FakeAndroidPlatformView { ...@@ -406,6 +416,7 @@ class FakeAndroidPlatformView {
} }
} }
@immutable
class FakeAndroidMotionEvent { class FakeAndroidMotionEvent {
const FakeAndroidMotionEvent(this.action, this.pointerIds, this.pointers); const FakeAndroidMotionEvent(this.action, this.pointerIds, this.pointers);
...@@ -431,8 +442,9 @@ class FakeAndroidMotionEvent { ...@@ -431,8 +442,9 @@ class FakeAndroidMotionEvent {
} }
} }
@immutable
class FakeUiKitView { class FakeUiKitView {
FakeUiKitView(this.id, this.type, [this.creationParams]); const FakeUiKitView(this.id, this.type, [this.creationParams]);
final int id; final int id;
final String type; final String type;
...@@ -457,8 +469,9 @@ class FakeUiKitView { ...@@ -457,8 +469,9 @@ class FakeUiKitView {
} }
} }
@immutable
class FakeHtmlPlatformView { class FakeHtmlPlatformView {
FakeHtmlPlatformView(this.id, this.type); const FakeHtmlPlatformView(this.id, this.type);
final int id; final int id;
final String type; final String type;
......
...@@ -40,8 +40,8 @@ void main() { ...@@ -40,8 +40,8 @@ void main() {
expect( expect(
viewsController.views, viewsController.views,
unorderedEquals(<FakeAndroidPlatformView>[ unorderedEquals(<FakeAndroidPlatformView>[
FakeAndroidPlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr),
FakeAndroidPlatformView(1, 'webview', const Size(200.0, 300.0), AndroidViewController.kAndroidLayoutDirectionRtl), const FakeAndroidPlatformView(1, 'webview', Size(200.0, 300.0), AndroidViewController.kAndroidLayoutDirectionRtl),
])); ]));
}); });
...@@ -70,7 +70,7 @@ void main() { ...@@ -70,7 +70,7 @@ void main() {
expect( expect(
viewsController.views, viewsController.views,
unorderedEquals(<FakeAndroidPlatformView>[ unorderedEquals(<FakeAndroidPlatformView>[
FakeAndroidPlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr),
])); ]));
}); });
...@@ -96,8 +96,8 @@ void main() { ...@@ -96,8 +96,8 @@ void main() {
expect( expect(
viewsController.views, viewsController.views,
unorderedEquals(<FakeAndroidPlatformView>[ unorderedEquals(<FakeAndroidPlatformView>[
FakeAndroidPlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr),
FakeAndroidPlatformView(1, 'webview', const Size(500.0, 500.0), AndroidViewController.kAndroidLayoutDirectionLtr), const FakeAndroidPlatformView(1, 'webview', Size(500.0, 500.0), AndroidViewController.kAndroidLayoutDirectionLtr),
])); ]));
}); });
...@@ -137,7 +137,7 @@ void main() { ...@@ -137,7 +137,7 @@ void main() {
expect( expect(
viewsController.views, viewsController.views,
unorderedEquals(<FakeAndroidPlatformView>[ unorderedEquals(<FakeAndroidPlatformView>[
FakeAndroidPlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr),
])); ]));
}); });
...@@ -150,7 +150,7 @@ void main() { ...@@ -150,7 +150,7 @@ void main() {
expect( expect(
viewsController.views, viewsController.views,
unorderedEquals(<FakeAndroidPlatformView>[ unorderedEquals(<FakeAndroidPlatformView>[
FakeAndroidPlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl),
])); ]));
}); });
}); });
...@@ -183,8 +183,8 @@ void main() { ...@@ -183,8 +183,8 @@ void main() {
expect( expect(
viewsController.views, viewsController.views,
unorderedEquals(<FakeUiKitView>[ unorderedEquals(<FakeUiKitView>[
FakeUiKitView(0, 'webview'), const FakeUiKitView(0, 'webview'),
FakeUiKitView(1, 'webview'), const FakeUiKitView(1, 'webview'),
]), ]),
); );
}); });
...@@ -214,7 +214,7 @@ void main() { ...@@ -214,7 +214,7 @@ void main() {
expect( expect(
viewsController.views, viewsController.views,
unorderedEquals(<FakeUiKitView>[ unorderedEquals(<FakeUiKitView>[
FakeUiKitView(0, 'webview'), const FakeUiKitView(0, 'webview'),
])); ]));
}); });
......
...@@ -103,7 +103,7 @@ class FakeImageStreamCompleter extends ImageStreamCompleter { ...@@ -103,7 +103,7 @@ class FakeImageStreamCompleter extends ImageStreamCompleter {
} }
class TestAssetImage extends AssetImage { class TestAssetImage extends AssetImage {
TestAssetImage(String name) : super(name); const TestAssetImage(String name) : super(name);
@override @override
ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) { ImageStreamCompleter load(AssetBundleImageKey key, DecoderCallback decode) {
......
...@@ -1622,6 +1622,7 @@ void main() { ...@@ -1622,6 +1622,7 @@ void main() {
}); });
} }
@immutable
class ConfigurationAwareKey { class ConfigurationAwareKey {
const ConfigurationAwareKey(this.provider, this.configuration) const ConfigurationAwareKey(this.provider, this.configuration)
: assert(provider != null), : assert(provider != null),
......
...@@ -9,6 +9,7 @@ class TestValueKey<T> extends ValueKey<T> { ...@@ -9,6 +9,7 @@ class TestValueKey<T> extends ValueKey<T> {
const TestValueKey(T value) : super(value); const TestValueKey(T value) : super(value);
} }
@immutable
class NotEquals { class NotEquals {
const NotEquals(); const NotEquals();
@override @override
......
...@@ -68,6 +68,7 @@ void main() { ...@@ -68,6 +68,7 @@ void main() {
LogicalKeyboardKey.keyC, LogicalKeyboardKey.keyC,
LogicalKeyboardKey.keyD, LogicalKeyboardKey.keyD,
); );
// ignore: prefer_const_literals_to_create_immutables, https://github.com/dart-lang/linter/issues/2026
final LogicalKeySet setFromSet = LogicalKeySet.fromSet(<LogicalKeyboardKey>{ final LogicalKeySet setFromSet = LogicalKeySet.fromSet(<LogicalKeyboardKey>{
LogicalKeyboardKey.keyA, LogicalKeyboardKey.keyA,
LogicalKeyboardKey.keyB, LogicalKeyboardKey.keyB,
...@@ -123,6 +124,7 @@ void main() { ...@@ -123,6 +124,7 @@ void main() {
LogicalKeyboardKey.keyB, LogicalKeyboardKey.keyB,
LogicalKeyboardKey.keyA, LogicalKeyboardKey.keyA,
); );
// ignore: prefer_const_literals_to_create_immutables, https://github.com/dart-lang/linter/issues/2026
final LogicalKeySet set4 = LogicalKeySet.fromSet(<LogicalKeyboardKey>{ final LogicalKeySet set4 = LogicalKeySet.fromSet(<LogicalKeyboardKey>{
LogicalKeyboardKey.keyD, LogicalKeyboardKey.keyD,
LogicalKeyboardKey.keyC, LogicalKeyboardKey.keyC,
...@@ -138,6 +140,7 @@ void main() { ...@@ -138,6 +140,7 @@ void main() {
expect(map.containsKey(LogicalKeySet(LogicalKeyboardKey.keyA)), isTrue); expect(map.containsKey(LogicalKeySet(LogicalKeyboardKey.keyA)), isTrue);
expect( expect(
set2, set2,
// ignore: prefer_const_literals_to_create_immutables, https://github.com/dart-lang/linter/issues/2026
equals(LogicalKeySet.fromSet(<LogicalKeyboardKey>{ equals(LogicalKeySet.fromSet(<LogicalKeyboardKey>{
LogicalKeyboardKey.keyA, LogicalKeyboardKey.keyA,
LogicalKeyboardKey.keyB, LogicalKeyboardKey.keyB,
......
...@@ -748,6 +748,7 @@ class CommonFinders { ...@@ -748,6 +748,7 @@ class CommonFinders {
} }
/// An immutable 2D floating-point offset used by Flutter Driver. /// An immutable 2D floating-point offset used by Flutter Driver.
@immutable
class DriverOffset { class DriverOffset {
/// Creates an offset. /// Creates an offset.
const DriverOffset(this.dx, this.dy); const DriverOffset(this.dx, this.dy);
......
...@@ -240,27 +240,27 @@ void main() { ...@@ -240,27 +240,27 @@ void main() {
test('isSameColorAs', () { test('isSameColorAs', () {
expect( expect(
const Color(0x87654321), const Color(0x87654321),
isSameColorAs(_CustomColor(0x87654321)), isSameColorAs(const _CustomColor(0x87654321)),
); );
expect( expect(
_CustomColor(0x87654321), const _CustomColor(0x87654321),
isSameColorAs(const Color(0x87654321)), isSameColorAs(const Color(0x87654321)),
); );
expect( expect(
const Color(0x12345678), const Color(0x12345678),
isNot(isSameColorAs(_CustomColor(0x87654321))), isNot(isSameColorAs(const _CustomColor(0x87654321))),
); );
expect( expect(
_CustomColor(0x87654321), const _CustomColor(0x87654321),
isNot(isSameColorAs(const Color(0x12345678))), isNot(isSameColorAs(const Color(0x12345678))),
); );
expect( expect(
_CustomColor(0xFF123456), const _CustomColor(0xFF123456),
isSameColorAs(_CustomColor(0xFF123456)..isEqual = false), isSameColorAs(const _CustomColor(0xFF123456, isEqual: false)),
); );
}); });
...@@ -704,9 +704,10 @@ class _FakeSemanticsNode extends SemanticsNode { ...@@ -704,9 +704,10 @@ class _FakeSemanticsNode extends SemanticsNode {
SemanticsData getSemanticsData() => data; SemanticsData getSemanticsData() => data;
} }
@immutable
class _CustomColor extends Color { class _CustomColor extends Color {
_CustomColor(int value) : super(value); const _CustomColor(int value, {this.isEqual}) : super(value);
bool isEqual; final bool isEqual;
@override @override
bool operator ==(Object other) => isEqual ?? super == other; bool operator ==(Object other) => isEqual ?? super == other;
......
...@@ -273,8 +273,9 @@ class _ManifestAssetBundle implements AssetBundle { ...@@ -273,8 +273,9 @@ class _ManifestAssetBundle implements AssetBundle {
List<File> additionalDependencies = <File>[]; List<File> additionalDependencies = <File>[];
} }
@immutable
class _Asset { class _Asset {
_Asset({ this.baseDir, this.relativeUri, this.entryUri }); const _Asset({ this.baseDir, this.relativeUri, this.entryUri });
final String baseDir; final String baseDir;
......
...@@ -98,39 +98,49 @@ class Fingerprinter { ...@@ -98,39 +98,49 @@ class Fingerprinter {
/// properties. /// properties.
/// ///
/// See [Fingerprinter]. /// See [Fingerprinter].
@immutable
class Fingerprint { class Fingerprint {
Fingerprint.fromBuildInputs(Map<String, String> properties, Iterable<String> inputPaths) { const Fingerprint._({
Map<String, String> checksums,
Map<String, String> properties,
}) : _checksums = checksums,
_properties = properties;
factory Fingerprint.fromBuildInputs(Map<String, String> properties, Iterable<String> inputPaths) {
final Iterable<File> files = inputPaths.map<File>(globals.fs.file); final Iterable<File> files = inputPaths.map<File>(globals.fs.file);
final Iterable<File> missingInputs = files.where((File file) => !file.existsSync()); final Iterable<File> missingInputs = files.where((File file) => !file.existsSync());
if (missingInputs.isNotEmpty) { if (missingInputs.isNotEmpty) {
throw Exception('Missing input files:\n' + missingInputs.join('\n')); throw Exception('Missing input files:\n' + missingInputs.join('\n'));
} }
return Fingerprint._(
_checksums = <String, String>{}; // ignore: prefer_const_literals_to_create_immutables, https://github.com/dart-lang/linter/issues/2025
for (final File file in files) { checksums: <String, String>{
final List<int> bytes = file.readAsBytesSync(); for (final File file in files)
_checksums[file.path] = md5.convert(bytes).toString(); file.path: md5.convert(file.readAsBytesSync()).toString(),
} },
_properties = <String, String>{...properties}; properties: <String, String>{...properties},
);
} }
/// Creates a Fingerprint from serialized JSON. /// Creates a Fingerprint from serialized JSON.
/// ///
/// Throws [Exception], if there is a version mismatch between the /// Throws [Exception], if there is a version mismatch between the
/// serializing framework and this framework. /// serializing framework and this framework.
Fingerprint.fromJson(String jsonData) { factory Fingerprint.fromJson(String jsonData) {
final Map<String, dynamic> content = castStringKeyedMap(json.decode(jsonData)); final Map<String, dynamic> content = castStringKeyedMap(json.decode(jsonData));
final String version = content['version'] as String; final String version = content['version'] as String;
if (version != globals.flutterVersion.frameworkRevision) { if (version != globals.flutterVersion.frameworkRevision) {
throw Exception('Incompatible fingerprint version: $version'); throw Exception('Incompatible fingerprint version: $version');
} }
_checksums = castStringKeyedMap(content['files'])?.cast<String,String>() ?? <String, String>{}; return Fingerprint._(
_properties = castStringKeyedMap(content['properties'])?.cast<String,String>() ?? <String, String>{}; checksums: castStringKeyedMap(content['files'])?.cast<String,String>() ?? <String, String>{},
properties: castStringKeyedMap(content['properties'])?.cast<String,String>() ?? <String, String>{},
);
} }
Map<String, String> _checksums; final Map<String, String> _checksums;
Map<String, String> _properties; final Map<String, String> _properties;
String toJson() => json.encode(<String, dynamic>{ String toJson() => json.encode(<String, dynamic>{
'version': globals.flutterVersion.frameworkRevision, 'version': globals.flutterVersion.frameworkRevision,
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:meta/meta.dart';
@immutable
class Version implements Comparable<Version> { class Version implements Comparable<Version> {
/// Creates a new [Version] object. /// Creates a new [Version] object.
factory Version(int major, int minor, int patch, {String text}) { factory Version(int major, int minor, int patch, {String text}) {
......
...@@ -480,10 +480,14 @@ abstract class Device { ...@@ -480,10 +480,14 @@ abstract class Device {
Future<void> takeScreenshot(File outputFile) => Future<void>.error('unimplemented'); Future<void> takeScreenshot(File outputFile) => Future<void>.error('unimplemented');
@nonVirtual
@override @override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode => id.hashCode; int get hashCode => id.hashCode;
@nonVirtual
@override @override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
bool operator ==(Object other) { bool operator ==(Object other) {
if (identical(this, other)) { if (identical(this, other)) {
return true; return true;
......
...@@ -481,14 +481,15 @@ class GroupedValidator extends DoctorValidator { ...@@ -481,14 +481,15 @@ class GroupedValidator extends DoctorValidator {
} }
} }
@immutable
class ValidationResult { class ValidationResult {
/// [ValidationResult.type] should only equal [ValidationResult.installed] /// [ValidationResult.type] should only equal [ValidationResult.installed]
/// if no [messages] are hints or errors. /// if no [messages] are hints or errors.
ValidationResult(this.type, this.messages, { this.statusInfo }); const ValidationResult(this.type, this.messages, { this.statusInfo });
factory ValidationResult.crash(Object error, [StackTrace stackTrace]) { factory ValidationResult.crash(Object error, [StackTrace stackTrace]) {
return ValidationResult(ValidationType.crash, <ValidationMessage>[ return ValidationResult(ValidationType.crash, <ValidationMessage>[
ValidationMessage.error( const ValidationMessage.error(
'Due to an error, the doctor check did not complete. ' 'Due to an error, the doctor check did not complete. '
'If the error message below is not helpful, ' 'If the error message below is not helpful, '
'please let us know about this issue at https://github.com/flutter/flutter/issues.'), 'please let us know about this issue at https://github.com/flutter/flutter/issues.'),
...@@ -555,10 +556,11 @@ class ValidationResult { ...@@ -555,10 +556,11 @@ class ValidationResult {
} }
} }
@immutable
class ValidationMessage { class ValidationMessage {
ValidationMessage(this.message) : type = ValidationMessageType.information; const ValidationMessage(this.message) : type = ValidationMessageType.information;
ValidationMessage.error(this.message) : type = ValidationMessageType.error; const ValidationMessage.error(this.message) : type = ValidationMessageType.error;
ValidationMessage.hint(this.message) : type = ValidationMessageType.hint; const ValidationMessage.hint(this.message) : type = ValidationMessageType.hint;
final ValidationMessageType type; final ValidationMessageType type;
bool get isError => type == ValidationMessageType.error; bool get isError => type == ValidationMessageType.error;
...@@ -714,7 +716,7 @@ abstract class IntelliJValidator extends DoctorValidator { ...@@ -714,7 +716,7 @@ abstract class IntelliJValidator extends DoctorValidator {
final List<ValidationMessage> messages = <ValidationMessage>[]; final List<ValidationMessage> messages = <ValidationMessage>[];
if (pluginsPath == null) { if (pluginsPath == null) {
messages.add(ValidationMessage.error('Invalid IntelliJ version number.')); messages.add(const ValidationMessage.error('Invalid IntelliJ version number.'));
} else { } else {
messages.add(ValidationMessage(userMessages.intellijLocation(installPath))); messages.add(ValidationMessage(userMessages.intellijLocation(installPath)));
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
import 'dart:async'; import 'dart:async';
import 'dart:math' as math; import 'dart:math' as math;
import 'package:meta/meta.dart';
import 'android/android_emulator.dart'; import 'android/android_emulator.dart';
import 'android/android_sdk.dart'; import 'android/android_sdk.dart';
import 'base/context.dart'; import 'base/context.dart';
...@@ -214,8 +216,9 @@ abstract class EmulatorDiscovery { ...@@ -214,8 +216,9 @@ abstract class EmulatorDiscovery {
Future<List<Emulator>> get emulators; Future<List<Emulator>> get emulators;
} }
@immutable
abstract class Emulator { abstract class Emulator {
Emulator(this.id, this.hasConfig); const Emulator(this.id, this.hasConfig);
final String id; final String id;
final bool hasConfig; final bool hasConfig;
......
...@@ -22,7 +22,7 @@ class IOSEmulators extends EmulatorDiscovery { ...@@ -22,7 +22,7 @@ class IOSEmulators extends EmulatorDiscovery {
} }
class IOSEmulator extends Emulator { class IOSEmulator extends Emulator {
IOSEmulator(String id) : super(id, true); const IOSEmulator(String id) : super(id, true);
@override @override
String get name => 'iOS Simulator'; String get name => 'iOS Simulator';
......
...@@ -37,7 +37,7 @@ class LinuxDoctorValidator extends DoctorValidator { ...@@ -37,7 +37,7 @@ class LinuxDoctorValidator extends DoctorValidator {
} }
if (clangResult == null || clangResult.exitCode != 0) { if (clangResult == null || clangResult.exitCode != 0) {
validationType = ValidationType.missing; validationType = ValidationType.missing;
messages.add(ValidationMessage.error('clang++ is not installed')); messages.add(const ValidationMessage.error('clang++ is not installed'));
} else { } else {
final String firstLine = (clangResult.stdout as String).split('\n').first.trim(); final String firstLine = (clangResult.stdout as String).split('\n').first.trim();
final String versionString = RegExp(r'[0-9]+\.[0-9]+\.[0-9]+').firstMatch(firstLine).group(0); final String versionString = RegExp(r'[0-9]+\.[0-9]+\.[0-9]+').firstMatch(firstLine).group(0);
...@@ -64,7 +64,7 @@ class LinuxDoctorValidator extends DoctorValidator { ...@@ -64,7 +64,7 @@ class LinuxDoctorValidator extends DoctorValidator {
} }
if (makeResult == null || makeResult.exitCode != 0) { if (makeResult == null || makeResult.exitCode != 0) {
validationType = ValidationType.missing; validationType = ValidationType.missing;
messages.add(ValidationMessage.error('make is not installed')); messages.add(const ValidationMessage.error('make is not installed'));
} else { } else {
final String firstLine = (makeResult.stdout as String).split('\n').first.trim(); final String firstLine = (makeResult.stdout as String).split('\n').first.trim();
messages.add(ValidationMessage(firstLine)); messages.add(ValidationMessage(firstLine));
......
...@@ -28,10 +28,10 @@ class ProxyValidator extends DoctorValidator { ...@@ -28,10 +28,10 @@ class ProxyValidator extends DoctorValidator {
final List<ValidationMessage> messages = <ValidationMessage>[]; final List<ValidationMessage> messages = <ValidationMessage>[];
if (_httpProxy.isNotEmpty) { if (_httpProxy.isNotEmpty) {
messages.add(ValidationMessage('HTTP_PROXY is set')); messages.add(const ValidationMessage('HTTP_PROXY is set'));
if (_noProxy.isEmpty) { if (_noProxy.isEmpty) {
messages.add(ValidationMessage.hint('NO_PROXY is not set')); messages.add(const ValidationMessage.hint('NO_PROXY is not set'));
} else { } else {
messages.add(ValidationMessage('NO_PROXY is $_noProxy')); messages.add(ValidationMessage('NO_PROXY is $_noProxy'));
for (final String host in const <String>['127.0.0.1', 'localhost']) { for (final String host in const <String>['127.0.0.1', 'localhost']) {
......
...@@ -30,7 +30,7 @@ class VsCode { ...@@ -30,7 +30,7 @@ class VsCode {
// If the extensions directory doesn't exist at all, the listSync() // If the extensions directory doesn't exist at all, the listSync()
// below will fail, so just bail out early. // below will fail, so just bail out early.
final ValidationMessage notInstalledMessage = ValidationMessage.error( const ValidationMessage notInstalledMessage = ValidationMessage.error(
'Flutter extension not installed; install from\n$extensionMarketplaceUrl'); 'Flutter extension not installed; install from\n$extensionMarketplaceUrl');
if (!globals.fs.isDirectorySync(extensionDirectory)) { if (!globals.fs.isDirectorySync(extensionDirectory)) {
_validationMessages.add(notInstalledMessage); _validationMessages.add(notInstalledMessage);
......
...@@ -36,7 +36,7 @@ class WebValidator extends DoctorValidator { ...@@ -36,7 +36,7 @@ class WebValidator extends DoctorValidator {
ValidationMessage('$kChromeEnvironment = $chrome') ValidationMessage('$kChromeEnvironment = $chrome')
else else
if (!canRunChrome) if (!canRunChrome)
ValidationMessage.hint('Cannot find Chrome. Try setting ' const ValidationMessage.hint('Cannot find Chrome. Try setting '
'$kChromeEnvironment to a Chrome executable.') '$kChromeEnvironment to a Chrome executable.')
else else
ValidationMessage('Chrome at $chrome'), ValidationMessage('Chrome at $chrome'),
......
...@@ -801,11 +801,11 @@ class PassingValidator extends DoctorValidator { ...@@ -801,11 +801,11 @@ class PassingValidator extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[ const List<ValidationMessage> messages = <ValidationMessage>[
ValidationMessage('A helpful message'), ValidationMessage('A helpful message'),
ValidationMessage('A second, somewhat longer helpful message'), ValidationMessage('A second, somewhat longer helpful message'),
]; ];
return ValidationResult(ValidationType.installed, messages, statusInfo: 'with statusInfo'); return const ValidationResult(ValidationType.installed, messages, statusInfo: 'with statusInfo');
} }
} }
...@@ -814,12 +814,12 @@ class MissingValidator extends DoctorValidator { ...@@ -814,12 +814,12 @@ class MissingValidator extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[ const List<ValidationMessage> messages = <ValidationMessage>[
ValidationMessage.error('A useful error message'), ValidationMessage.error('A useful error message'),
ValidationMessage('A message that is not an error'), ValidationMessage('A message that is not an error'),
ValidationMessage.hint('A hint message'), ValidationMessage.hint('A hint message'),
]; ];
return ValidationResult(ValidationType.missing, messages); return const ValidationResult(ValidationType.missing, messages);
} }
} }
...@@ -828,12 +828,12 @@ class NotAvailableValidator extends DoctorValidator { ...@@ -828,12 +828,12 @@ class NotAvailableValidator extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[ const List<ValidationMessage> messages = <ValidationMessage>[
ValidationMessage.error('A useful error message'), ValidationMessage.error('A useful error message'),
ValidationMessage('A message that is not an error'), ValidationMessage('A message that is not an error'),
ValidationMessage.hint('A hint message'), ValidationMessage.hint('A hint message'),
]; ];
return ValidationResult(ValidationType.notAvailable, messages); return const ValidationResult(ValidationType.notAvailable, messages);
} }
} }
...@@ -842,12 +842,12 @@ class PartialValidatorWithErrors extends DoctorValidator { ...@@ -842,12 +842,12 @@ class PartialValidatorWithErrors extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[ const List<ValidationMessage> messages = <ValidationMessage>[
ValidationMessage.error('An error message indicating partial installation'), ValidationMessage.error('An error message indicating partial installation'),
ValidationMessage.hint('Maybe a hint will help the user'), ValidationMessage.hint('Maybe a hint will help the user'),
ValidationMessage('An extra message with some verbose details'), ValidationMessage('An extra message with some verbose details'),
]; ];
return ValidationResult(ValidationType.partial, messages); return const ValidationResult(ValidationType.partial, messages);
} }
} }
...@@ -856,11 +856,11 @@ class PartialValidatorWithHintsOnly extends DoctorValidator { ...@@ -856,11 +856,11 @@ class PartialValidatorWithHintsOnly extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[ const List<ValidationMessage> messages = <ValidationMessage>[
ValidationMessage.hint('There is a hint here'), ValidationMessage.hint('There is a hint here'),
ValidationMessage('But there is no error'), ValidationMessage('But there is no error'),
]; ];
return ValidationResult(ValidationType.partial, messages); return const ValidationResult(ValidationType.partial, messages);
} }
} }
...@@ -1006,10 +1006,10 @@ class PassingGroupedValidator extends DoctorValidator { ...@@ -1006,10 +1006,10 @@ class PassingGroupedValidator extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[ const List<ValidationMessage> messages = <ValidationMessage>[
ValidationMessage('A helpful message'), ValidationMessage('A helpful message'),
]; ];
return ValidationResult(ValidationType.installed, messages); return const ValidationResult(ValidationType.installed, messages);
} }
} }
...@@ -1018,10 +1018,10 @@ class MissingGroupedValidator extends DoctorValidator { ...@@ -1018,10 +1018,10 @@ class MissingGroupedValidator extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[ const List<ValidationMessage> messages = <ValidationMessage>[
ValidationMessage.error('A useful error message'), ValidationMessage.error('A useful error message'),
]; ];
return ValidationResult(ValidationType.missing, messages); return const ValidationResult(ValidationType.missing, messages);
} }
} }
...@@ -1030,10 +1030,10 @@ class PartialGroupedValidator extends DoctorValidator { ...@@ -1030,10 +1030,10 @@ class PartialGroupedValidator extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[ const List<ValidationMessage> messages = <ValidationMessage>[
ValidationMessage.error('An error message for partial installation'), ValidationMessage.error('An error message for partial installation'),
]; ];
return ValidationResult(ValidationType.partial, messages); return const ValidationResult(ValidationType.partial, messages);
} }
} }
...@@ -1042,10 +1042,10 @@ class PassingGroupedValidatorWithStatus extends DoctorValidator { ...@@ -1042,10 +1042,10 @@ class PassingGroupedValidatorWithStatus extends DoctorValidator {
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
final List<ValidationMessage> messages = <ValidationMessage>[ const List<ValidationMessage> messages = <ValidationMessage>[
ValidationMessage('A different message'), ValidationMessage('A different message'),
]; ];
return ValidationResult(ValidationType.installed, messages, statusInfo: 'A status message'); return const ValidationResult(ValidationType.installed, messages, statusInfo: 'A status message');
} }
} }
......
...@@ -31,7 +31,7 @@ void main() { ...@@ -31,7 +31,7 @@ void main() {
const String emulatorID = '1234'; const String emulatorID = '1234';
final AndroidEmulator emulator = AndroidEmulator( final AndroidEmulator emulator = AndroidEmulator(
emulatorID, emulatorID,
<String, String>{'name': 'test'}, const <String, String>{'name': 'test'},
); );
expect(emulator.id, emulatorID); expect(emulator.id, emulatorID);
expect(emulator.hasConfig, true); expect(emulator.hasConfig, true);
......
...@@ -64,10 +64,10 @@ void main() { ...@@ -64,10 +64,10 @@ void main() {
}, },
); );
final Fingerprint fingerprint = fingerprinter.buildFingerprint(); final Fingerprint fingerprint = fingerprinter.buildFingerprint();
expect(fingerprint, Fingerprint.fromBuildInputs(<String, String>{ expect(fingerprint, Fingerprint.fromBuildInputs(const <String, String>{
'foo': 'bar', 'foo': 'bar',
'wibble': 'wobble', 'wibble': 'wobble',
}, <String>['a.dart'])); }, const <String>['a.dart']));
}, overrides: contextOverrides); }, overrides: contextOverrides);
testUsingContext('creates fingerprint with file checksums', () { testUsingContext('creates fingerprint with file checksums', () {
...@@ -85,10 +85,10 @@ void main() { ...@@ -85,10 +85,10 @@ void main() {
}, },
); );
final Fingerprint fingerprint = fingerprinter.buildFingerprint(); final Fingerprint fingerprint = fingerprinter.buildFingerprint();
expect(fingerprint, Fingerprint.fromBuildInputs(<String, String>{ expect(fingerprint, Fingerprint.fromBuildInputs(const <String, String>{
'bar': 'baz', 'bar': 'baz',
'wobble': 'womble', 'wobble': 'womble',
}, <String>['a.dart', 'b.dart'])); }, const <String>['a.dart', 'b.dart']));
}, overrides: contextOverrides); }, overrides: contextOverrides);
testUsingContext('fingerprint does not match if not present', () { testUsingContext('fingerprint does not match if not present', () {
...@@ -248,7 +248,7 @@ void main() { ...@@ -248,7 +248,7 @@ void main() {
testUsingContext('throws if any input file does not exist', () { testUsingContext('throws if any input file does not exist', () {
globals.fs.file('a.dart').createSync(); globals.fs.file('a.dart').createSync();
expect( expect(
() => Fingerprint.fromBuildInputs(<String, String>{}, <String>['a.dart', 'b.dart']), () => Fingerprint.fromBuildInputs(const <String, String>{}, const <String>['a.dart', 'b.dart']),
throwsException, throwsException,
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -259,7 +259,7 @@ void main() { ...@@ -259,7 +259,7 @@ void main() {
testUsingContext('populates checksums for valid files', () { testUsingContext('populates checksums for valid files', () {
globals.fs.file('a.dart').writeAsStringSync('This is a'); globals.fs.file('a.dart').writeAsStringSync('This is a');
globals.fs.file('b.dart').writeAsStringSync('This is b'); globals.fs.file('b.dart').writeAsStringSync('This is b');
final Fingerprint fingerprint = Fingerprint.fromBuildInputs(<String, String>{}, <String>['a.dart', 'b.dart']); final Fingerprint fingerprint = Fingerprint.fromBuildInputs(const <String, String>{}, const <String>['a.dart', 'b.dart']);
final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson())); final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson()));
expect(jsonObject['files'], hasLength(2)); expect(jsonObject['files'], hasLength(2));
...@@ -271,14 +271,14 @@ void main() { ...@@ -271,14 +271,14 @@ void main() {
}); });
testUsingContext('includes framework version', () { testUsingContext('includes framework version', () {
final Fingerprint fingerprint = Fingerprint.fromBuildInputs(<String, String>{}, <String>[]); final Fingerprint fingerprint = Fingerprint.fromBuildInputs(const <String, String>{}, const <String>[]);
final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson())); final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson()));
expect(jsonObject['version'], mockVersion.frameworkRevision); expect(jsonObject['version'], mockVersion.frameworkRevision);
}, overrides: <Type, Generator>{FlutterVersion: () => mockVersion}); }, overrides: <Type, Generator>{FlutterVersion: () => mockVersion});
testUsingContext('includes provided properties', () { testUsingContext('includes provided properties', () {
final Fingerprint fingerprint = Fingerprint.fromBuildInputs(<String, String>{'a': 'A', 'b': 'B'}, <String>[]); final Fingerprint fingerprint = Fingerprint.fromBuildInputs(const <String, String>{'a': 'A', 'b': 'B'}, const <String>[]);
final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson())); final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson()));
expect(jsonObject['properties'], hasLength(2)); expect(jsonObject['properties'], hasLength(2));
...@@ -347,7 +347,7 @@ void main() { ...@@ -347,7 +347,7 @@ void main() {
final String jsonString = json.encode(<String, dynamic>{ final String jsonString = json.encode(<String, dynamic>{
'version': kVersion, 'version': kVersion,
}); });
expect(Fingerprint.fromJson(jsonString), Fingerprint.fromBuildInputs(<String, String>{}, <String>[])); expect(Fingerprint.fromJson(jsonString), Fingerprint.fromBuildInputs(const <String, String>{}, const <String>[]));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => mockVersion, FlutterVersion: () => mockVersion,
}); });
......
...@@ -45,11 +45,11 @@ void main() { ...@@ -45,11 +45,11 @@ void main() {
}); });
testUsingContext('getEmulatorsById', () async { testUsingContext('getEmulatorsById', () async {
final _MockEmulator emulator1 = const _MockEmulator emulator1 =
_MockEmulator('Nexus_5', 'Nexus 5', 'Google'); _MockEmulator('Nexus_5', 'Nexus 5', 'Google');
final _MockEmulator emulator2 = const _MockEmulator emulator2 =
_MockEmulator('Nexus_5X_API_27_x86', 'Nexus 5X', 'Google'); _MockEmulator('Nexus_5X_API_27_x86', 'Nexus 5X', 'Google');
final _MockEmulator emulator3 = const _MockEmulator emulator3 =
_MockEmulator('iOS Simulator', 'iOS Simulator', 'Apple'); _MockEmulator('iOS Simulator', 'iOS Simulator', 'Apple');
final List<Emulator> emulators = <Emulator>[ final List<Emulator> emulators = <Emulator>[
emulator1, emulator1,
...@@ -137,7 +137,7 @@ void main() { ...@@ -137,7 +137,7 @@ void main() {
}); });
}); });
testUsingContext('runs correct launch commands', () async { testUsingContext('runs correct launch commands', () async {
final Emulator emulator = IOSEmulator('ios'); const Emulator emulator = IOSEmulator('ios');
await emulator.launch(); await emulator.launch();
expect(didAttemptToRunSimulator, equals(true)); expect(didAttemptToRunSimulator, equals(true));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -160,7 +160,7 @@ class TestEmulatorManager extends EmulatorManager { ...@@ -160,7 +160,7 @@ class TestEmulatorManager extends EmulatorManager {
} }
class _MockEmulator extends Emulator { class _MockEmulator extends Emulator {
_MockEmulator(String id, this.name, this.manufacturer) const _MockEmulator(String id, this.name, this.manufacturer)
: super(id, true); : super(id, true);
@override @override
......
...@@ -27,7 +27,7 @@ void main() { ...@@ -27,7 +27,7 @@ void main() {
final ValidationResult result = await linuxDoctorValidator.validate(); final ValidationResult result = await linuxDoctorValidator.validate();
expect(result.type, ValidationType.installed); expect(result.type, ValidationType.installed);
expect(result.messages, <ValidationMessage>[ expect(result.messages, const <ValidationMessage>[
ValidationMessage('clang++ 4.0.1'), ValidationMessage('clang++ 4.0.1'),
ValidationMessage('GNU Make 4.1'), ValidationMessage('GNU Make 4.1'),
]); ]);
...@@ -50,7 +50,7 @@ void main() { ...@@ -50,7 +50,7 @@ void main() {
final ValidationResult result = await linuxDoctorValidator.validate(); final ValidationResult result = await linuxDoctorValidator.validate();
expect(result.type, ValidationType.partial); expect(result.type, ValidationType.partial);
expect(result.messages, <ValidationMessage>[ expect(result.messages, const <ValidationMessage>[
ValidationMessage.error('clang++ 2.0.1 is below minimum version of 3.4.0'), ValidationMessage.error('clang++ 2.0.1 is below minimum version of 3.4.0'),
ValidationMessage('GNU Make 4.1'), ValidationMessage('GNU Make 4.1'),
]); ]);
...@@ -73,7 +73,7 @@ void main() { ...@@ -73,7 +73,7 @@ void main() {
final ValidationResult result = await linuxDoctorValidator.validate(); final ValidationResult result = await linuxDoctorValidator.validate();
expect(result.type, ValidationType.missing); expect(result.type, ValidationType.missing);
expect(result.messages, <ValidationMessage>[ expect(result.messages, const <ValidationMessage>[
ValidationMessage('clang++ 4.0.1'), ValidationMessage('clang++ 4.0.1'),
ValidationMessage.error('make is not installed'), ValidationMessage.error('make is not installed'),
]); ]);
...@@ -96,7 +96,7 @@ void main() { ...@@ -96,7 +96,7 @@ void main() {
final ValidationResult result = await linuxDoctorValidator.validate(); final ValidationResult result = await linuxDoctorValidator.validate();
expect(result.type, ValidationType.missing); expect(result.type, ValidationType.missing);
expect(result.messages, <ValidationMessage>[ expect(result.messages, const <ValidationMessage>[
ValidationMessage.error('clang++ is not installed'), ValidationMessage.error('clang++ is not installed'),
ValidationMessage('GNU Make 4.1'), ValidationMessage('GNU Make 4.1'),
]); ]);
......
...@@ -63,7 +63,7 @@ void main() { ...@@ -63,7 +63,7 @@ void main() {
final ValidationResult result = await webValidator.validate(); final ValidationResult result = await webValidator.validate();
expect(result.messages, <ValidationMessage>[ expect(result.messages, const <ValidationMessage>[
ValidationMessage.hint( ValidationMessage.hint(
'Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.'), 'Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.'),
]); ]);
......
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