Skip to content

Commit

Permalink
enable lint unnecessary_const (flutter#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
a14n authored and goderbauer committed Aug 1, 2018
1 parent 195e922 commit 6683c7a
Show file tree
Hide file tree
Showing 53 changed files with 110 additions and 114 deletions.
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ linter:
- type_init_formals
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
- unnecessary_null_aware_assignments
Expand Down
2 changes: 1 addition & 1 deletion packages/android_alarm_manager/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Future<Null> main() async {
final int oneShotID = 2;
printHelloMessage("Hello, main()!");
runApp(const Center(
child: const Text('Hello, world!', textDirection: TextDirection.ltr)));
child: Text('Hello, world!', textDirection: TextDirection.ltr)));
await AndroidAlarmManager.periodic(
const Duration(minutes: 1), helloAlarmID, printHello);
await AndroidAlarmManager.periodic(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:flutter/services.dart';
class AndroidAlarmManager {
static const String _channelName = 'plugins.flutter.io/android_alarm_manager';
static const MethodChannel _channel =
const MethodChannel(_channelName, const JSONMethodCodec());
MethodChannel(_channelName, JSONMethodCodec());

/// Schedules a one-shot timer to run `callback` after time `delay`.
///
Expand Down
4 changes: 2 additions & 2 deletions packages/android_intent/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class MyHomePage extends StatelessWidget {
void _createAlarm() {
final AndroidIntent intent = const AndroidIntent(
action: 'android.intent.action.SET_ALARM',
arguments: const <String, dynamic>{
'android.intent.extra.alarm.DAYS': const <int>[2, 3, 4, 5, 6],
arguments: <String, dynamic>{
'android.intent.extra.alarm.DAYS': <int>[2, 3, 4, 5, 6],
'android.intent.extra.alarm.HOUR': 21,
'android.intent.extra.alarm.MINUTES': 30,
'android.intent.extra.alarm.SKIP_UI': true,
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome> {
if (controller == null || !controller.value.isInitialized) {
return const Text(
'Tap a camera',
style: const TextStyle(
style: TextStyle(
color: Colors.white,
fontSize: 24.0,
fontWeight: FontWeight.w900,
Expand Down
4 changes: 2 additions & 2 deletions packages/cloud_firestore/lib/src/firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ part of cloud_firestore;
/// You can get an instance by calling [Firestore.instance].
class Firestore {
@visibleForTesting
static const MethodChannel channel = const MethodChannel(
static const MethodChannel channel = MethodChannel(
'plugins.flutter.io/cloud_firestore',
const StandardMethodCodec(const FirestoreMessageCodec()),
StandardMethodCodec(FirestoreMessageCodec()),
);

static final Map<int, StreamController<QuerySnapshot>> _queryObservers =
Expand Down
7 changes: 4 additions & 3 deletions packages/cloud_firestore/test/cloud_firestore_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ void main() {
final List<MethodCall> log = <MethodCall>[];
CollectionReference collectionReference;
Transaction transaction;
const Map<String, dynamic> kMockDocumentSnapshotData =
const <String, dynamic>{'1': 2};
const Map<String, dynamic> kMockDocumentSnapshotData = <String, dynamic>{
'1': 2
};

setUp(() async {
mockHandleId = 0;
Expand Down Expand Up @@ -556,7 +557,7 @@ void main() {
});

group('FirestoreMessageCodec', () {
const MessageCodec<dynamic> codec = const FirestoreMessageCodec();
const MessageCodec<dynamic> codec = FirestoreMessageCodec();
final DateTime testTime = new DateTime(2015, 10, 30, 11, 16);
test('should encode and decode simple messages', () {
_checkEncodeDecode<dynamic>(codec, testTime);
Expand Down
2 changes: 1 addition & 1 deletion packages/cloud_functions/lib/cloud_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CloudFunctionsException implements Exception {
/// You can get an instance by calling [CloudFunctions.instance].
class CloudFunctions {
@visibleForTesting
static const MethodChannel channel = const MethodChannel('cloud_functions');
static const MethodChannel channel = MethodChannel('cloud_functions');

static CloudFunctions _instance = new CloudFunctions();

Expand Down
4 changes: 2 additions & 2 deletions packages/connectivity/lib/connectivity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import 'package:flutter/services.dart';
enum ConnectivityResult { wifi, mobile, none }

const MethodChannel _methodChannel =
const MethodChannel('plugins.flutter.io/connectivity');
MethodChannel('plugins.flutter.io/connectivity');

const EventChannel _eventChannel =
const EventChannel('plugins.flutter.io/connectivity_status');
EventChannel('plugins.flutter.io/connectivity_status');

class Connectivity {
Stream<ConnectivityResult> _onConnectivityChanged;
Expand Down
2 changes: 1 addition & 1 deletion packages/device_info/lib/device_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:flutter/services.dart';
class DeviceInfoPlugin {
/// Channel used to communicate to native code.
static const MethodChannel channel =
const MethodChannel('plugins.flutter.io/device_info');
MethodChannel('plugins.flutter.io/device_info');

DeviceInfoPlugin();

Expand Down
16 changes: 8 additions & 8 deletions packages/firebase_admob/lib/firebase_admob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,35 +110,35 @@ class AdSize {
});

/// The standard banner (320x50) size.
static const AdSize banner = const AdSize._(
static const AdSize banner = AdSize._(
width: 320,
height: 50,
adSizeType: AdSizeType.WidthAndHeight,
);

/// The large banner (320x100) size.
static const AdSize largeBanner = const AdSize._(
static const AdSize largeBanner = AdSize._(
width: 320,
height: 100,
adSizeType: AdSizeType.WidthAndHeight,
);

/// The medium rectangle (300x250) size.
static const AdSize mediumRectangle = const AdSize._(
static const AdSize mediumRectangle = AdSize._(
width: 300,
height: 250,
adSizeType: AdSizeType.WidthAndHeight,
);

/// The full banner (468x60) size.
static const AdSize fullBanner = const AdSize._(
static const AdSize fullBanner = AdSize._(
width: 468,
height: 60,
adSizeType: AdSizeType.WidthAndHeight,
);

/// The leaderboard (728x90) size.
static const AdSize leaderboard = const AdSize._(
static const AdSize leaderboard = AdSize._(
width: 728,
height: 90,
adSizeType: AdSizeType.WidthAndHeight,
Expand All @@ -151,7 +151,7 @@ class AdSize {
/// calculation based on the displaying device's height. For more info see the
/// [Android](https://developers.google.com/admob/android/banner) and
/// [iOS](https://developers.google.com/admob/ios/banner) banner ad guides.
static const AdSize smartBanner = const AdSize._(
static const AdSize smartBanner = AdSize._(
width: 0,
height: 0,
adSizeType: AdSizeType.SmartBanner,
Expand Down Expand Up @@ -430,7 +430,7 @@ class FirebaseAdMob {
final MethodChannel _channel;

static const Map<String, MobileAdEvent> _methodToMobileAdEvent =
const <String, MobileAdEvent>{
<String, MobileAdEvent>{
'onAdLoaded': MobileAdEvent.loaded,
'onAdFailedToLoad': MobileAdEvent.failedToLoad,
'onAdClicked': MobileAdEvent.clicked,
Expand All @@ -441,7 +441,7 @@ class FirebaseAdMob {
};

static const Map<String, RewardedVideoAdEvent> _methodToRewardedVideoAdEvent =
const <String, RewardedVideoAdEvent>{
<String, RewardedVideoAdEvent>{
'onRewarded': RewardedVideoAdEvent.rewarded,
'onRewardedVideoAdClosed': RewardedVideoAdEvent.closed,
'onRewardedVideoAdFailedToLoad': RewardedVideoAdEvent.failedToLoad,
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_admob/test/firebase_admob_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
group('FirebaseAdMob', () {
const MethodChannel channel =
const MethodChannel('plugins.flutter.io/firebase_admob');
MethodChannel('plugins.flutter.io/firebase_admob');

final List<MethodCall> log = <MethodCall>[];
final FirebaseAdMob admob = new FirebaseAdMob.private(channel);
Expand Down
3 changes: 1 addition & 2 deletions packages/firebase_analytics/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: _testSetUserProperty,
),
new Text(_message,
style:
const TextStyle(color: const Color.fromARGB(255, 0, 155, 0))),
style: const TextStyle(color: Color.fromARGB(255, 0, 155, 0))),
],
),
floatingActionButton: new FloatingActionButton(
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_analytics/lib/firebase_analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ void _requireValueAndCurrencyTogether(double value, String currency) {
/// Reserved event names that cannot be used.
///
/// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html
const List<String> _reservedEventNames = const <String>[
const List<String> _reservedEventNames = <String>[
'app_clear_data',
'app_uninstall',
'app_update',
Expand Down
4 changes: 2 additions & 2 deletions packages/firebase_auth/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ class _MyHomePageState extends State<MyHomePage> {
future: _message,
builder: (_, AsyncSnapshot<String> snapshot) {
return new Text(snapshot.data ?? '',
style: const TextStyle(
color: const Color.fromARGB(255, 0, 155, 0)));
style:
const TextStyle(color: Color.fromARGB(255, 0, 155, 0)));
}),
],
),
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_auth/lib/firebase_auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ typedef void PhoneCodeAutoRetrievalTimeout(String verificationId);

class FirebaseAuth {
@visibleForTesting
static const MethodChannel channel = const MethodChannel(
static const MethodChannel channel = MethodChannel(
'plugins.flutter.io/firebase_auth',
);

Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_core/lib/src/firebase_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FirebaseApp {
Platform.isIOS ? '__FIRAPP_DEFAULT' : '[DEFAULT]';

@visibleForTesting
static const MethodChannel channel = const MethodChannel(
static const MethodChannel channel = MethodChannel(
'plugins.flutter.io/firebase_core',
);

Expand Down
4 changes: 2 additions & 2 deletions packages/firebase_core/test/firebase_core_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
group('$FirebaseApp', () {
final List<MethodCall> log = <MethodCall>[];
const FirebaseApp testApp = const FirebaseApp(
const FirebaseApp testApp = FirebaseApp(
name: 'testApp',
);
const FirebaseOptions testOptions = const FirebaseOptions(
const FirebaseOptions testOptions = FirebaseOptions(
apiKey: 'testAPIKey',
bundleID: 'testBundleID',
clientID: 'testClientID',
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_database/lib/src/database_reference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class DatabaseReference extends Query {
}

class ServerValue {
static const Map<String, String> timestamp = const <String, String>{
static const Map<String, String> timestamp = <String, String>{
'.sv': 'timestamp'
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart';

void main() {
group('$FirebaseDatabase', () {
const MethodChannel channel = const MethodChannel(
const MethodChannel channel = MethodChannel(
'plugins.flutter.io/firebase_database',
);

Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_dynamic_links/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class _DynamicLinkScreen extends StatelessWidget {
title: const Text('Hello World DeepLink'),
),
body: const Center(
child: const Text('Hello, World!'),
child: Text('Hello, World!'),
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FirebaseDynamicLinks {

@visibleForTesting
static const MethodChannel channel =
const MethodChannel('plugins.flutter.io/firebase_dynamic_links');
MethodChannel('plugins.flutter.io/firebase_dynamic_links');

/// Singleton of [FirebaseDynamicLinks].
static final FirebaseDynamicLinks instance = new FirebaseDynamicLinks._();
Expand Down
14 changes: 7 additions & 7 deletions packages/firebase_ml_vision/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ class _MyHomePageState extends State<_MyHomePage> {
),
child: _imageSize == null || _scanResults == null
? const Center(
child: const Text(
child: Text(
'Scanning...',
style: const TextStyle(
style: TextStyle(
color: Colors.green,
fontSize: 30.0,
),
Expand All @@ -156,27 +156,27 @@ class _MyHomePageState extends State<_MyHomePage> {
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<Detector>>[
const PopupMenuItem<Detector>(
child: const Text('Detect Barcode'),
child: Text('Detect Barcode'),
value: Detector.barcode,
),
const PopupMenuItem<Detector>(
child: const Text('Detect Face'),
child: Text('Detect Face'),
value: Detector.face,
),
const PopupMenuItem<Detector>(
child: const Text('Detect Label'),
child: Text('Detect Label'),
value: Detector.label,
),
const PopupMenuItem<Detector>(
child: const Text('Detect Text'),
child: Text('Detect Text'),
value: Detector.text,
),
],
),
],
),
body: _imageFile == null
? const Center(child: const Text('No image selected.'))
? const Center(child: Text('No image selected.'))
: _buildImage(),
floatingActionButton: new FloatingActionButton(
onPressed: _getAndScanImage,
Expand Down
30 changes: 15 additions & 15 deletions packages/firebase_ml_vision/lib/src/barcode_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,49 +117,49 @@ class BarcodeFormat {
const BarcodeFormat._(this.value);

/// Barcode format constant representing the union of all supported formats.
static const BarcodeFormat all = const BarcodeFormat._(0xFFFF);
static const BarcodeFormat all = BarcodeFormat._(0xFFFF);

/// Barcode format unknown to the current SDK.
static const BarcodeFormat unknown = const BarcodeFormat._(0);
static const BarcodeFormat unknown = BarcodeFormat._(0);

/// Barcode format constant for Code 128.
static const BarcodeFormat code128 = const BarcodeFormat._(0x0001);
static const BarcodeFormat code128 = BarcodeFormat._(0x0001);

/// Barcode format constant for Code 39.
static const BarcodeFormat code39 = const BarcodeFormat._(0x0002);
static const BarcodeFormat code39 = BarcodeFormat._(0x0002);

/// Barcode format constant for Code 93.
static const BarcodeFormat code93 = const BarcodeFormat._(0x0004);
static const BarcodeFormat code93 = BarcodeFormat._(0x0004);

/// Barcode format constant for CodaBar.
static const BarcodeFormat codabar = const BarcodeFormat._(0x0008);
static const BarcodeFormat codabar = BarcodeFormat._(0x0008);

/// Barcode format constant for Data Matrix.
static const BarcodeFormat dataMatrix = const BarcodeFormat._(0x0010);
static const BarcodeFormat dataMatrix = BarcodeFormat._(0x0010);

/// Barcode format constant for EAN-13.
static const BarcodeFormat ean13 = const BarcodeFormat._(0x0020);
static const BarcodeFormat ean13 = BarcodeFormat._(0x0020);

/// Barcode format constant for EAN-8.
static const BarcodeFormat ean8 = const BarcodeFormat._(0x0040);
static const BarcodeFormat ean8 = BarcodeFormat._(0x0040);

/// Barcode format constant for ITF (Interleaved Two-of-Five).
static const BarcodeFormat itf = const BarcodeFormat._(0x0080);
static const BarcodeFormat itf = BarcodeFormat._(0x0080);

/// Barcode format constant for QR Code.
static const BarcodeFormat qrCode = const BarcodeFormat._(0x0100);
static const BarcodeFormat qrCode = BarcodeFormat._(0x0100);

/// Barcode format constant for UPC-A.
static const BarcodeFormat upca = const BarcodeFormat._(0x0200);
static const BarcodeFormat upca = BarcodeFormat._(0x0200);

/// Barcode format constant for UPC-E.
static const BarcodeFormat upce = const BarcodeFormat._(0x0400);
static const BarcodeFormat upce = BarcodeFormat._(0x0400);

/// Barcode format constant for PDF-417.
static const BarcodeFormat pdf417 = const BarcodeFormat._(0x0800);
static const BarcodeFormat pdf417 = BarcodeFormat._(0x0800);

/// Barcode format constant for AZTEC.
static const BarcodeFormat aztec = const BarcodeFormat._(0x1000);
static const BarcodeFormat aztec = BarcodeFormat._(0x1000);

/// Raw BarcodeFormat value.
final int value;
Expand Down
Loading

0 comments on commit 6683c7a

Please sign in to comment.