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