Skip to content

Commit 8fe2999

Browse files
abhijeethpredbrogdon
authored andcommitted
Removed redundant "const" and "new" assignments & Formatted code. (flutter#58)
1 parent be35972 commit 8fe2999

File tree

16 files changed

+87
-75
lines changed

16 files changed

+87
-75
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
# Name/Organization <email address>
55

66
Google Inc.
7+
Abhijeeth Padarthi <rkinabhi@gmail.com>

jsonexample/lib/built_value/built_value_serializers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'package:jsonexample/built_value/built_simple_object.dart';
1212

1313
part 'built_value_serializers.g.dart';
1414

15-
@SerializersFor(const [
15+
@SerializersFor([
1616
BuiltSimpleObject,
1717
BuiltComplexObject,
1818
])

jsonexample/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class MyHomePage extends StatelessWidget {
4646
],
4747
),
4848
),
49-
body: new SafeArea(
49+
body: SafeArea(
5050
bottom: false,
5151
child: TabBarView(
5252
children: [

jsonexample/lib/widgets.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class ComplexObjectView extends StatelessWidget {
129129
if (simpleObjects == null) {
130130
return [
131131
const Padding(
132-
padding: const EdgeInsets.symmetric(vertical: 8.0),
132+
padding: EdgeInsets.symmetric(vertical: 8.0),
133133
child: Text('NULL'),
134134
),
135135
];
@@ -138,7 +138,7 @@ class ComplexObjectView extends StatelessWidget {
138138
if (simpleObjects.length == 0) {
139139
return [
140140
const Padding(
141-
padding: const EdgeInsets.symmetric(vertical: 4.0),
141+
padding: EdgeInsets.symmetric(vertical: 4.0),
142142
child: Text('[]'),
143143
),
144144
];

place_tracker/lib/place_map.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ class PlaceMapState extends State<PlaceMap> {
233233
Scaffold.of(context).showSnackBar(
234234
SnackBar(
235235
duration: Duration(seconds: 3),
236-
content: const Text('New place added.',
237-
style: const TextStyle(fontSize: 16.0)),
236+
content:
237+
const Text('New place added.', style: TextStyle(fontSize: 16.0)),
238238
action: SnackBarAction(
239239
label: 'Edit',
240240
onPressed: () async {

platform_view_swift/lib/main.dart

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import 'package:flutter/material.dart';
77
import 'package:flutter/services.dart';
88

99
void main() {
10-
runApp(new PlatformView());
10+
runApp(PlatformView());
1111
}
1212

1313
class PlatformView extends StatelessWidget {
1414
@override
1515
Widget build(BuildContext context) {
16-
return new MaterialApp(
16+
return MaterialApp(
1717
title: 'Platform View',
18-
theme: new ThemeData(
18+
theme: ThemeData(
1919
primarySwatch: Colors.grey,
2020
),
2121
home: const MyHomePage(title: 'Platform View'),
@@ -29,12 +29,12 @@ class MyHomePage extends StatefulWidget {
2929
final String title;
3030

3131
@override
32-
_MyHomePageState createState() => new _MyHomePageState();
32+
_MyHomePageState createState() => _MyHomePageState();
3333
}
3434

3535
class _MyHomePageState extends State<MyHomePage> {
3636
static const MethodChannel _methodChannel =
37-
const MethodChannel('samples.flutter.io/platform_view_swift');
37+
MethodChannel('samples.flutter.io/platform_view_swift');
3838

3939
int _counter = 0;
4040

@@ -53,48 +53,47 @@ class _MyHomePageState extends State<MyHomePage> {
5353
}
5454

5555
@override
56-
Widget build(BuildContext context) => new Scaffold(
57-
appBar: new AppBar(
58-
title: new Text(widget.title),
56+
Widget build(BuildContext context) => Scaffold(
57+
appBar: AppBar(
58+
title: Text(widget.title),
5959
),
60-
body: new Column(
60+
body: Column(
6161
crossAxisAlignment: CrossAxisAlignment.start,
6262
children: <Widget>[
63-
new Expanded(
64-
child: new Center(
65-
child: new Column(
63+
Expanded(
64+
child: Center(
65+
child: Column(
6666
mainAxisAlignment: MainAxisAlignment.center,
6767
children: <Widget>[
68-
new Text(
68+
Text(
6969
'Button tapped $_counter time${_counter == 1 ? '' : 's'}.',
7070
style: const TextStyle(fontSize: 17.0),
7171
),
72-
new Padding(
72+
Padding(
7373
padding: const EdgeInsets.all(18.0),
74-
child: new RaisedButton(
74+
child: RaisedButton(
7575
child: const Text('Continue in iOS view'),
7676
onPressed: _launchPlatformCount),
7777
),
7878
],
7979
),
8080
),
8181
),
82-
new Container(
82+
Container(
8383
padding: const EdgeInsets.only(bottom: 15.0, left: 5.0),
84-
child: new Row(
84+
child: Row(
8585
children: <Widget>[
86-
new Image.asset('assets/flutter-mark-square-64.png',
87-
scale: 1.5),
86+
Image.asset('assets/flutter-mark-square-64.png', scale: 1.5),
8887
const Text(
8988
'Flutter',
90-
style: const TextStyle(fontSize: 30.0),
89+
style: TextStyle(fontSize: 30.0),
9190
),
9291
],
9392
),
9493
),
9594
],
9695
),
97-
floatingActionButton: new FloatingActionButton(
96+
floatingActionButton: FloatingActionButton(
9897
onPressed: _incrementCounter,
9998
tooltip: 'Increment',
10099
child: const Icon(Icons.add),

shrine/lib/colors.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
import 'package:flutter/material.dart';
1616

17-
const kShrinePink50 = const Color(0xFFFEEAE6);
18-
const kShrinePink100 = const Color(0xFFFEDBD0);
19-
const kShrinePink300 = const Color(0xFFFBB8AC);
20-
const kShrinePink400 = const Color(0xFFEAA4A4);
17+
const kShrinePink50 = Color(0xFFFEEAE6);
18+
const kShrinePink100 = Color(0xFFFEDBD0);
19+
const kShrinePink300 = Color(0xFFFBB8AC);
20+
const kShrinePink400 = Color(0xFFEAA4A4);
2121

22-
const kShrineBrown900 = const Color(0xFF442B2D);
23-
const kShrineBrown600 = const Color(0xFF7D4F52);
22+
const kShrineBrown900 = Color(0xFF442B2D);
23+
const kShrineBrown600 = Color(0xFF7D4F52);
2424

25-
const kShrineErrorRed = const Color(0xFFC5032B);
25+
const kShrineErrorRed = Color(0xFFC5032B);
2626

27-
const kShrineSurfaceWhite = const Color(0xFFFFFBFA);
27+
const kShrineSurfaceWhite = Color(0xFFFFFBFA);
2828
const kShrineBackgroundWhite = Colors.white;

shrine/lib/expanding_bottom_sheet.dart

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import 'model/product.dart';
2525
import 'shopping_cart.dart';
2626

2727
// These curves define the emphasized easing curve.
28-
const Cubic _kAccelerateCurve = const Cubic(0.548, 0.0, 0.757, 0.464);
29-
const Cubic _kDecelerateCurve = const Cubic(0.23, 0.94, 0.41, 1.0);
28+
const Cubic _kAccelerateCurve = Cubic(0.548, 0.0, 0.757, 0.464);
29+
const Cubic _kDecelerateCurve = Cubic(0.23, 0.94, 0.41, 1.0);
3030
// The time at which the accelerate and decelerate curves switch off
3131
const double _kPeakVelocityTime = 0.248210;
3232
// Percent (as a decimal) of animation that should be completed at _peakVelocityTime
@@ -48,7 +48,7 @@ class ExpandingBottomSheet extends StatefulWidget {
4848
_ExpandingBottomSheetState createState() => _ExpandingBottomSheetState();
4949

5050
static _ExpandingBottomSheetState of(BuildContext context,
51-
{bool isNullOk: false}) {
51+
{bool isNullOk = false}) {
5252
assert(isNullOk != null);
5353
assert(context != null);
5454
final _ExpandingBottomSheetState result = context
@@ -115,8 +115,10 @@ double _getPeakPoint({double begin, double end}) {
115115
return begin + (end - begin) * _kPeakVelocityProgress;
116116
}
117117

118-
class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with TickerProviderStateMixin {
119-
final GlobalKey _expandingBottomSheetKey = GlobalKey(debugLabel: 'Expanding bottom sheet');
118+
class _ExpandingBottomSheetState extends State<ExpandingBottomSheet>
119+
with TickerProviderStateMixin {
120+
final GlobalKey _expandingBottomSheetKey =
121+
GlobalKey(debugLabel: 'Expanding bottom sheet');
120122

121123
// The width of the Material, calculated by _widthFor() & based on the number
122124
// of products in the cart. 64.0 is the width when there are 0 products
@@ -163,7 +165,8 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
163165
peak: _getPeakPoint(begin: _width, end: screenWidth),
164166
end: screenWidth,
165167
isForward: false,
166-
parent: CurvedAnimation(parent: _controller.view, curve: Interval(0.0, 0.87)),
168+
parent: CurvedAnimation(
169+
parent: _controller.view, curve: Interval(0.0, 0.87)),
167170
);
168171
}
169172
}
@@ -174,7 +177,8 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
174177

175178
return _getEmphasizedEasingAnimation(
176179
begin: _kCartHeight,
177-
peak: _kCartHeight + (screenHeight - _kCartHeight) * _kPeakVelocityProgress,
180+
peak: _kCartHeight +
181+
(screenHeight - _kCartHeight) * _kPeakVelocityProgress,
178182
end: screenHeight,
179183
isForward: true,
180184
parent: _controller.view,
@@ -189,7 +193,8 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
189193
parent: _controller.view,
190194
curve: Interval(0.434, 1.0, curve: Curves.linear), // not used
191195
// only the reverseCurve will be used
192-
reverseCurve: Interval(0.434, 1.0, curve: Curves.fastOutSlowIn.flipped),
196+
reverseCurve:
197+
Interval(0.434, 1.0, curve: Curves.fastOutSlowIn.flipped),
193198
),
194199
);
195200
}
@@ -259,7 +264,8 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
259264
// Returns true if the cart is open or opening and false otherwise.
260265
bool get _isOpen {
261266
final AnimationStatus status = _controller.status;
262-
return status == AnimationStatus.completed || status == AnimationStatus.forward;
267+
return status == AnimationStatus.completed ||
268+
status == AnimationStatus.forward;
263269
}
264270

265271
// Opens the ExpandingBottomSheet if it's closed, otherwise does nothing.
@@ -438,7 +444,8 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
438444
super.initState();
439445
_list = _ListModel(
440446
listKey: _listKey,
441-
initialItems: ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList(),
447+
initialItems:
448+
ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList(),
442449
removedItemBuilder: _buildRemovedThumbnail,
443450
);
444451
_internalList = List<int>.from(_list.list);
@@ -451,12 +458,15 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
451458
return product;
452459
}
453460

454-
Widget _buildRemovedThumbnail(int item, BuildContext context, Animation<double> animation) {
461+
Widget _buildRemovedThumbnail(
462+
int item, BuildContext context, Animation<double> animation) {
455463
return ProductThumbnail(animation, animation, _productWithId(item));
456464
}
457465

458-
Widget _buildThumbnail(BuildContext context, int index, Animation<double> animation) {
459-
Animation<double> thumbnailSize = Tween<double>(begin: 0.8, end: 1.0).animate(
466+
Widget _buildThumbnail(
467+
BuildContext context, int index, Animation<double> animation) {
468+
Animation<double> thumbnailSize =
469+
Tween<double>(begin: 0.8, end: 1.0).animate(
460470
CurvedAnimation(
461471
curve: Interval(0.33, 1.0, curve: Curves.easeIn),
462472
parent: animation,
@@ -468,15 +478,17 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
468478
parent: animation,
469479
);
470480

471-
return ProductThumbnail(thumbnailSize, opacity, _productWithId(_list[index]));
481+
return ProductThumbnail(
482+
thumbnailSize, opacity, _productWithId(_list[index]));
472483
}
473484

474485
// If the lists are the same length, assume nothing has changed.
475486
// If the internalList is shorter than the ListModel, an item has been removed.
476487
// If the internalList is longer, then an item has been added.
477488
void _updateLists() {
478489
// Update _internalList based on the model
479-
_internalList = ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList();
490+
_internalList =
491+
ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList();
480492
Set<int> internalSet = Set<int>.from(_internalList);
481493
Set<int> listSet = Set<int>.from(_list.list);
482494

@@ -550,9 +562,11 @@ class ExtraProductsNumber extends StatelessWidget {
550562
if (model.productsInCart.length > 3) {
551563
int numOverflowProducts = _calculateOverflow(model);
552564
// Maximum of 99 so padding doesn't get messy.
553-
int displayedOverflowProducts = numOverflowProducts <= 99 ? numOverflowProducts : 99;
565+
int displayedOverflowProducts =
566+
numOverflowProducts <= 99 ? numOverflowProducts : 99;
554567
return Container(
555-
child: Text('+$displayedOverflowProducts',
568+
child: Text(
569+
'+$displayedOverflowProducts',
556570
style: Theme.of(context).primaryTextTheme.button,
557571
),
558572
);
@@ -606,8 +620,8 @@ class ProductThumbnail extends StatelessWidget {
606620
class _ListModel {
607621
_ListModel(
608622
{@required this.listKey,
609-
@required this.removedItemBuilder,
610-
Iterable<int> initialItems})
623+
@required this.removedItemBuilder,
624+
Iterable<int> initialItems})
611625
: assert(listKey != null),
612626
assert(removedItemBuilder != null),
613627
_items = List<int>.from(initialItems ?? <int>[]);
@@ -637,7 +651,8 @@ class _ListModel {
637651
void _removeAt(int index) {
638652
final int removedItem = _items.removeAt(index);
639653
if (removedItem != null) {
640-
_animatedList.removeItem(index, (BuildContext context, Animation<double> animation) {
654+
_animatedList.removeItem(index,
655+
(BuildContext context, Animation<double> animation) {
641656
return removedItemBuilder(removedItem, context, animation);
642657
});
643658
}

shrine/lib/home.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import 'supplemental/asymmetric_view.dart';
2424
class ProductPage extends StatelessWidget {
2525
final Category category;
2626

27-
const ProductPage({this.category: Category.all});
27+
const ProductPage({this.category = Category.all});
2828

2929
@override
3030
Widget build(BuildContext context) {
@@ -41,11 +41,8 @@ class HomePage extends StatelessWidget {
4141
final ExpandingBottomSheet expandingBottomSheet;
4242
final Backdrop backdrop;
4343

44-
const HomePage({
45-
Key key,
46-
this.expandingBottomSheet,
47-
this.backdrop
48-
}) : super(key: key);
44+
const HomePage({Key key, this.expandingBottomSheet, this.backdrop})
45+
: super(key: key);
4946

5047
@override
5148
Widget build(BuildContext context) {

shrine/lib/shopping_cart.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
6363
width: _leftColumnWidth,
6464
child: IconButton(
6565
icon: const Icon(Icons.keyboard_arrow_down),
66-
onPressed: () => ExpandingBottomSheet.of(context).close()
67-
),
66+
onPressed: () =>
67+
ExpandingBottomSheet.of(context).close()),
6868
),
6969
Text(
7070
'CART',

0 commit comments

Comments
 (0)