Unverified Commit 10f721c8 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

use const instead of final with const declarations (#14253)

parent 34ff00a7
......@@ -292,7 +292,7 @@ class SvgPath {
final List<SvgPathCommand> commands;
final double opacity;
static final String _pathCommandAtom = ' *([a-zA-Z]) *([\-\.0-9 ,]*)';
static const String _pathCommandAtom = ' *([a-zA-Z]) *([\-\.0-9 ,]*)';
static final RegExp _pathCommandValidator = new RegExp('^($_pathCommandAtom)*\$');
static final RegExp _pathCommandMatcher = new RegExp(_pathCommandAtom);
......@@ -460,7 +460,7 @@ class _Transform {
}
final String _transformCommandAtom = ' *([^(]+)\\(([^)]*)\\)';
const String _transformCommandAtom = ' *([^(]+)\\(([^)]*)\\)';
final RegExp _transformValidator = new RegExp('^($_transformCommandAtom)*\$');
final RegExp _transformCommand = new RegExp(_transformCommandAtom);
......
......@@ -51,7 +51,7 @@ class TravelDestinationItem extends StatelessWidget {
: assert(destination != null && destination.isValid),
super(key: key);
static final double height = 366.0;
static const double height = 366.0;
final TravelDestination destination;
@override
......
......@@ -94,7 +94,7 @@ final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{
class _CardDataItem extends StatelessWidget {
const _CardDataItem({ this.page, this.data });
static final double height = 272.0;
static const double height = 272.0;
final _Page page;
final _CardData data;
......
......@@ -200,11 +200,11 @@ class _FeaturePriceItem extends _PriceItem {
class _HeadingLayout extends MultiChildLayoutDelegate {
_HeadingLayout();
static final String price = 'price';
static final String image = 'image';
static final String title = 'title';
static final String description = 'description';
static final String vendor = 'vendor';
static const String price = 'price';
static const String image = 'image';
static const String title = 'title';
static const String description = 'description';
static const String vendor = 'vendor';
@override
void performLayout(Size size) {
......
......@@ -101,10 +101,10 @@ class _VendorItem extends StatelessWidget {
class _HeadingLayout extends MultiChildLayoutDelegate {
_HeadingLayout();
static final String image = 'image';
static final String icon = 'icon';
static final String product = 'product';
static final String vendor = 'vendor';
static const String image = 'image';
static const String icon = 'icon';
static const String product = 'product';
static const String vendor = 'vendor';
@override
void performLayout(Size size) {
......
......@@ -82,7 +82,7 @@ const List<Demo> demos = const <Demo>[
const Demo('Typography'),
];
final FileSystem _fs = const LocalFileSystem();
const FileSystem _fs = const LocalFileSystem();
const Duration kWaitBetweenActions = const Duration(milliseconds: 250);
......
......@@ -25,8 +25,8 @@ final List<List<String>> _kNameLines = _kDialogText
final TextStyle _kDaveStyle = new TextStyle(color: Colors.indigo.shade400, height: 1.8);
final TextStyle _kHalStyle = new TextStyle(color: Colors.red.shade400, fontFamily: 'monospace');
final TextStyle _kBold = const TextStyle(fontWeight: FontWeight.bold);
final TextStyle _kUnderline = const TextStyle(
const TextStyle _kBold = const TextStyle(fontWeight: FontWeight.bold);
const TextStyle _kUnderline = const TextStyle(
decoration: TextDecoration.underline,
decorationColor: const Color(0xFF000000),
decorationStyle: TextDecorationStyle.wavy
......
......@@ -182,7 +182,7 @@ const double _kPadding = 8.0;
const Color _kTrackColor = const Color(0xFFB5B5B5);
const double _kSliderHeight = 2.0 * (CupertinoThumbPainter.radius + _kPadding);
const double _kSliderWidth = 176.0; // Matches Material Design slider.
final Duration _kDiscreteTransitionDuration = const Duration(milliseconds: 500);
const Duration _kDiscreteTransitionDuration = const Duration(milliseconds: 500);
const double _kAdjustmentUnit = 0.1; // Matches iOS implementation of material slider.
......
......@@ -289,7 +289,7 @@ final Color _kActiveTrackColor = Colors.grey;
final Tween<double> _kReactionRadiusTween = new Tween<double>(begin: _kThumbRadius, end: _kReactionRadius);
final Tween<double> _kThumbRadiusTween = new Tween<double>(begin: _kThumbRadius, end: _kActiveThumbRadius);
final ColorTween _kTickColorTween = new ColorTween(begin: Colors.transparent, end: Colors.black54);
final Duration _kDiscreteTransitionDuration = const Duration(milliseconds: 500);
const Duration _kDiscreteTransitionDuration = const Duration(milliseconds: 500);
const double _kLabelBalloonRadius = 14.0;
final Tween<double> _kLabelBalloonCenterTween = new Tween<double>(begin: 0.0, end: -_kLabelBalloonRadius * 2.0);
......
......@@ -165,9 +165,9 @@ class _AccountDetailsLayout extends MultiChildLayoutDelegate {
_AccountDetailsLayout({ @required this.textDirection });
static final String accountName = 'accountName';
static final String accountEmail = 'accountEmail';
static final String dropdownIcon = 'dropdownIcon';
static const String accountName = 'accountName';
static const String accountEmail = 'accountEmail';
static const String dropdownIcon = 'dropdownIcon';
final TextDirection textDirection;
......
......@@ -55,7 +55,7 @@ class RelativeRect {
}
/// A rect that covers the entire container.
static final RelativeRect fill = const RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0);
static const RelativeRect fill = const RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0);
/// Distance from the left side of the container to the left side of this rectangle.
///
......
......@@ -843,10 +843,10 @@ class _InspectorOverlayRenderState {
int get hashCode => hashValues(overlayRect, selected, hashList(candidates), tooltip);
}
final int _kMaxTooltipLines = 5;
final Color _kTooltipBackgroundColor = const Color.fromARGB(230, 60, 60, 60);
final Color _kHighlightedRenderObjectFillColor = const Color.fromARGB(128, 128, 128, 255);
final Color _kHighlightedRenderObjectBorderColor = const Color.fromARGB(128, 64, 64, 128);
const int _kMaxTooltipLines = 5;
const Color _kTooltipBackgroundColor = const Color.fromARGB(230, 60, 60, 60);
const Color _kHighlightedRenderObjectFillColor = const Color.fromARGB(128, 128, 128, 255);
const Color _kHighlightedRenderObjectBorderColor = const Color.fromARGB(128, 64, 64, 128);
/// A layer that outlines the selected [RenderObject] and candidate render
/// objects that also match the last pointer location.
......
......@@ -6,7 +6,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
final Key blockKey = const Key('test');
const Key blockKey = const Key('test');
void main() {
testWidgets('Cannot scroll a non-overflowing block', (WidgetTester tester) async {
......
......@@ -53,14 +53,14 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new DecoratedBox(decoration: kBoxDecorationA),
new Positioned(
children: const <Widget>[
const DecoratedBox(decoration: kBoxDecorationA),
const Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(decoration: kBoxDecorationB),
child: const DecoratedBox(decoration: kBoxDecorationB),
),
new DecoratedBox(decoration: kBoxDecorationC),
const DecoratedBox(decoration: kBoxDecorationC),
],
),
);
......@@ -74,18 +74,18 @@ void main() {
await tester.pumpWidget(
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
children: const <Widget>[
const Positioned(
bottom: 5.0,
right: 7.0,
child: new DecoratedBox(decoration: kBoxDecorationA),
child: const DecoratedBox(decoration: kBoxDecorationA),
),
new Positioned(
const Positioned(
top: 10.0,
left: 10.0,
child: new DecoratedBox(decoration: kBoxDecorationB),
child: const DecoratedBox(decoration: kBoxDecorationB),
),
new DecoratedBox(decoration: kBoxDecorationC),
const DecoratedBox(decoration: kBoxDecorationC),
],
),
);
......@@ -96,9 +96,9 @@ void main() {
kNonPositioned,
]);
final DecoratedBox kDecoratedBoxA = new DecoratedBox(decoration: kBoxDecorationA);
final DecoratedBox kDecoratedBoxB = new DecoratedBox(decoration: kBoxDecorationB);
final DecoratedBox kDecoratedBoxC = new DecoratedBox(decoration: kBoxDecorationC);
final DecoratedBox kDecoratedBoxA = const DecoratedBox(decoration: kBoxDecorationA);
final DecoratedBox kDecoratedBoxB = const DecoratedBox(decoration: kBoxDecorationB);
final DecoratedBox kDecoratedBoxC = const DecoratedBox(decoration: kBoxDecorationC);
await tester.pumpWidget(
new Stack(
......@@ -254,13 +254,13 @@ void main() {
new Stack(
textDirection: TextDirection.ltr,
children: <Widget>[
new Positioned(
const Positioned(
top: 5.0,
bottom: 8.0,
child: new Positioned(
child: const Positioned(
top: 6.0,
left: 7.0,
child: new DecoratedBox(decoration: kBoxDecorationB),
child: const DecoratedBox(decoration: kBoxDecorationB),
),
),
],
......@@ -276,10 +276,10 @@ void main() {
new Container(
child: new Row(
children: <Widget>[
new Positioned(
const Positioned(
top: 6.0,
left: 7.0,
child: new DecoratedBox(decoration: kBoxDecorationB),
child: const DecoratedBox(decoration: kBoxDecorationB),
),
],
),
......
......@@ -22,18 +22,18 @@ void main() {
}
await tester.pumpWidget(
new FlipWidget(
left: new DecoratedBox(decoration: kBoxDecorationA),
right: new DecoratedBox(decoration: kBoxDecorationB)
const FlipWidget(
left: const DecoratedBox(decoration: kBoxDecorationA),
right: const DecoratedBox(decoration: kBoxDecorationB)
)
);
checkTree(kBoxDecorationA);
await tester.pumpWidget(
new FlipWidget(
left: new DecoratedBox(decoration: kBoxDecorationB),
right: new DecoratedBox(decoration: kBoxDecorationA)
const FlipWidget(
left: const DecoratedBox(decoration: kBoxDecorationB),
right: const DecoratedBox(decoration: kBoxDecorationA)
)
);
......@@ -46,9 +46,9 @@ void main() {
checkTree(kBoxDecorationA);
await tester.pumpWidget(
new FlipWidget(
left: new DecoratedBox(decoration: kBoxDecorationA),
right: new DecoratedBox(decoration: kBoxDecorationB)
const FlipWidget(
left: const DecoratedBox(decoration: kBoxDecorationA),
right: const DecoratedBox(decoration: kBoxDecorationB)
)
);
......@@ -60,7 +60,7 @@ void main() {
new FlipWidget(
key: const Key('rebuild test'),
left: new TestBuildCounter(),
right: new DecoratedBox(decoration: kBoxDecorationB)
right: const DecoratedBox(decoration: kBoxDecorationB)
)
);
......
......@@ -6,15 +6,15 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
final BoxDecoration kBoxDecorationA = const BoxDecoration(
const BoxDecoration kBoxDecorationA = const BoxDecoration(
color: const Color(0xFFFF0000),
);
final BoxDecoration kBoxDecorationB = const BoxDecoration(
const BoxDecoration kBoxDecorationB = const BoxDecoration(
color: const Color(0xFF00FF00),
);
final BoxDecoration kBoxDecorationC = const BoxDecoration(
const BoxDecoration kBoxDecorationC = const BoxDecoration(
color: const Color(0xFF0000FF),
);
......@@ -24,7 +24,7 @@ class TestBuildCounter extends StatelessWidget {
@override
Widget build(BuildContext context) {
buildCount += 1;
return new DecoratedBox(decoration: kBoxDecorationA);
return const DecoratedBox(decoration: kBoxDecorationA);
}
}
......
......@@ -12,7 +12,7 @@ import 'package:path/path.dart' as path;
import 'common.dart';
import 'timeline.dart';
final JsonEncoder _prettyEncoder = const JsonEncoder.withIndent(' ');
const JsonEncoder _prettyEncoder = const JsonEncoder.withIndent(' ');
/// The maximum amount of time considered safe to spend for a frame's build
/// phase. Anything past that is in the danger of missing the frame as 60FPS.
......
......@@ -279,7 +279,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
fontSize: 40.0,
);
static final Widget _kPreTestMessage = const Center(
static const Widget _kPreTestMessage = const Center(
child: const Text(
'Test starting...',
style: _kMessageStyle,
......@@ -287,7 +287,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
)
);
static final Widget _kPostTestMessage = const Center(
static const Widget _kPostTestMessage = const Center(
child: const Text(
'Test finished.',
style: _kMessageStyle,
......
......@@ -15,7 +15,7 @@ typedef bool WidgetPredicate(Widget widget);
typedef bool ElementPredicate(Element element);
/// Some frequently used widget [Finder]s.
final CommonFinders find = const CommonFinders._();
const CommonFinders find = const CommonFinders._();
/// Provides lightweight syntax for getting frequently used widget [Finder]s.
///
......
......@@ -200,7 +200,7 @@ abstract class IOSApp extends ApplicationPackage {
}
class BuildableIOSApp extends IOSApp {
static final String kBundleName = 'Runner.app';
static const String kBundleName = 'Runner.app';
BuildableIOSApp({
this.appDirectory,
......
......@@ -17,16 +17,16 @@ import '../base/version.dart';
import '../cache.dart';
import '../globals.dart';
final String noCocoaPodsConsequence = '''
const String noCocoaPodsConsequence = '''
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
For more info, see https://flutter.io/platform-plugins''';
final String cocoaPodsInstallInstructions = '''
const String cocoaPodsInstallInstructions = '''
brew install cocoapods
pod setup''';
final String cocoaPodsUpgradeInstructions = '''
const String cocoaPodsUpgradeInstructions = '''
brew upgrade cocoapods
pod setup''';
......
......@@ -1025,7 +1025,7 @@ class Isolate extends ServiceObjectOwner {
_updateHeaps(map['_heaps'], mapIsRef);
}
static final int kIsolateReloadBarred = 1005;
static const int kIsolateReloadBarred = 1005;
Future<Map<String, dynamic>> reloadSources(
{ bool pause: false,
......
......@@ -29,7 +29,7 @@ void main() {
});
}
final String _aaptData = '''
const String _aaptData = '''
package: name='io.flutter.gallery' versionCode='1' versionName='0.0.1' platformBuildVersionName='NMR1'
sdkVersion:'14'
targetSdkVersion:'21'
......
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