Removed redundant "const" and "new" assignments & Formatted code. (#58)

pull/60/head
Abhijeeth Padarthi 6 years ago committed by Andrew Brogdon
parent be35972637
commit 8fe2999ee8

@ -4,3 +4,4 @@
# Name/Organization <email address>
Google Inc.
Abhijeeth Padarthi <rkinabhi@gmail.com>

@ -12,7 +12,7 @@ import 'package:jsonexample/built_value/built_simple_object.dart';
part 'built_value_serializers.g.dart';
@SerializersFor(const [
@SerializersFor([
BuiltSimpleObject,
BuiltComplexObject,
])

@ -46,7 +46,7 @@ class MyHomePage extends StatelessWidget {
],
),
),
body: new SafeArea(
body: SafeArea(
bottom: false,
child: TabBarView(
children: [

@ -129,7 +129,7 @@ class ComplexObjectView extends StatelessWidget {
if (simpleObjects == null) {
return [
const Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Text('NULL'),
),
];
@ -138,7 +138,7 @@ class ComplexObjectView extends StatelessWidget {
if (simpleObjects.length == 0) {
return [
const Padding(
padding: const EdgeInsets.symmetric(vertical: 4.0),
padding: EdgeInsets.symmetric(vertical: 4.0),
child: Text('[]'),
),
];

@ -233,8 +233,8 @@ class PlaceMapState extends State<PlaceMap> {
Scaffold.of(context).showSnackBar(
SnackBar(
duration: Duration(seconds: 3),
content: const Text('New place added.',
style: const TextStyle(fontSize: 16.0)),
content:
const Text('New place added.', style: TextStyle(fontSize: 16.0)),
action: SnackBarAction(
label: 'Edit',
onPressed: () async {

@ -7,15 +7,15 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(new PlatformView());
runApp(PlatformView());
}
class PlatformView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Platform View',
theme: new ThemeData(
theme: ThemeData(
primarySwatch: Colors.grey,
),
home: const MyHomePage(title: 'Platform View'),
@ -29,12 +29,12 @@ class MyHomePage extends StatefulWidget {
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
static const MethodChannel _methodChannel =
const MethodChannel('samples.flutter.io/platform_view_swift');
MethodChannel('samples.flutter.io/platform_view_swift');
int _counter = 0;
@ -53,25 +53,25 @@ class _MyHomePageState extends State<MyHomePage> {
}
@override
Widget build(BuildContext context) => new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: new Column(
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Expanded(
child: new Center(
child: new Column(
Expanded(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
Text(
'Button tapped $_counter time${_counter == 1 ? '' : 's'}.',
style: const TextStyle(fontSize: 17.0),
),
new Padding(
Padding(
padding: const EdgeInsets.all(18.0),
child: new RaisedButton(
child: RaisedButton(
child: const Text('Continue in iOS view'),
onPressed: _launchPlatformCount),
),
@ -79,22 +79,21 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
),
new Container(
Container(
padding: const EdgeInsets.only(bottom: 15.0, left: 5.0),
child: new Row(
child: Row(
children: <Widget>[
new Image.asset('assets/flutter-mark-square-64.png',
scale: 1.5),
Image.asset('assets/flutter-mark-square-64.png', scale: 1.5),
const Text(
'Flutter',
style: const TextStyle(fontSize: 30.0),
style: TextStyle(fontSize: 30.0),
),
],
),
),
],
),
floatingActionButton: new FloatingActionButton(
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),

@ -14,15 +14,15 @@
import 'package:flutter/material.dart';
const kShrinePink50 = const Color(0xFFFEEAE6);
const kShrinePink100 = const Color(0xFFFEDBD0);
const kShrinePink300 = const Color(0xFFFBB8AC);
const kShrinePink400 = const Color(0xFFEAA4A4);
const kShrinePink50 = Color(0xFFFEEAE6);
const kShrinePink100 = Color(0xFFFEDBD0);
const kShrinePink300 = Color(0xFFFBB8AC);
const kShrinePink400 = Color(0xFFEAA4A4);
const kShrineBrown900 = const Color(0xFF442B2D);
const kShrineBrown600 = const Color(0xFF7D4F52);
const kShrineBrown900 = Color(0xFF442B2D);
const kShrineBrown600 = Color(0xFF7D4F52);
const kShrineErrorRed = const Color(0xFFC5032B);
const kShrineErrorRed = Color(0xFFC5032B);
const kShrineSurfaceWhite = const Color(0xFFFFFBFA);
const kShrineSurfaceWhite = Color(0xFFFFFBFA);
const kShrineBackgroundWhite = Colors.white;

@ -25,8 +25,8 @@ import 'model/product.dart';
import 'shopping_cart.dart';
// These curves define the emphasized easing curve.
const Cubic _kAccelerateCurve = const Cubic(0.548, 0.0, 0.757, 0.464);
const Cubic _kDecelerateCurve = const Cubic(0.23, 0.94, 0.41, 1.0);
const Cubic _kAccelerateCurve = Cubic(0.548, 0.0, 0.757, 0.464);
const Cubic _kDecelerateCurve = Cubic(0.23, 0.94, 0.41, 1.0);
// The time at which the accelerate and decelerate curves switch off
const double _kPeakVelocityTime = 0.248210;
// Percent (as a decimal) of animation that should be completed at _peakVelocityTime
@ -48,7 +48,7 @@ class ExpandingBottomSheet extends StatefulWidget {
_ExpandingBottomSheetState createState() => _ExpandingBottomSheetState();
static _ExpandingBottomSheetState of(BuildContext context,
{bool isNullOk: false}) {
{bool isNullOk = false}) {
assert(isNullOk != null);
assert(context != null);
final _ExpandingBottomSheetState result = context
@ -115,8 +115,10 @@ double _getPeakPoint({double begin, double end}) {
return begin + (end - begin) * _kPeakVelocityProgress;
}
class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with TickerProviderStateMixin {
final GlobalKey _expandingBottomSheetKey = GlobalKey(debugLabel: 'Expanding bottom sheet');
class _ExpandingBottomSheetState extends State<ExpandingBottomSheet>
with TickerProviderStateMixin {
final GlobalKey _expandingBottomSheetKey =
GlobalKey(debugLabel: 'Expanding bottom sheet');
// The width of the Material, calculated by _widthFor() & based on the number
// 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
peak: _getPeakPoint(begin: _width, end: screenWidth),
end: screenWidth,
isForward: false,
parent: CurvedAnimation(parent: _controller.view, curve: Interval(0.0, 0.87)),
parent: CurvedAnimation(
parent: _controller.view, curve: Interval(0.0, 0.87)),
);
}
}
@ -174,7 +177,8 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
return _getEmphasizedEasingAnimation(
begin: _kCartHeight,
peak: _kCartHeight + (screenHeight - _kCartHeight) * _kPeakVelocityProgress,
peak: _kCartHeight +
(screenHeight - _kCartHeight) * _kPeakVelocityProgress,
end: screenHeight,
isForward: true,
parent: _controller.view,
@ -189,7 +193,8 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
parent: _controller.view,
curve: Interval(0.434, 1.0, curve: Curves.linear), // not used
// only the reverseCurve will be used
reverseCurve: Interval(0.434, 1.0, curve: Curves.fastOutSlowIn.flipped),
reverseCurve:
Interval(0.434, 1.0, curve: Curves.fastOutSlowIn.flipped),
),
);
}
@ -259,7 +264,8 @@ class _ExpandingBottomSheetState extends State<ExpandingBottomSheet> with Ticker
// Returns true if the cart is open or opening and false otherwise.
bool get _isOpen {
final AnimationStatus status = _controller.status;
return status == AnimationStatus.completed || status == AnimationStatus.forward;
return status == AnimationStatus.completed ||
status == AnimationStatus.forward;
}
// Opens the ExpandingBottomSheet if it's closed, otherwise does nothing.
@ -438,7 +444,8 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
super.initState();
_list = _ListModel(
listKey: _listKey,
initialItems: ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList(),
initialItems:
ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList(),
removedItemBuilder: _buildRemovedThumbnail,
);
_internalList = List<int>.from(_list.list);
@ -451,12 +458,15 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
return product;
}
Widget _buildRemovedThumbnail(int item, BuildContext context, Animation<double> animation) {
Widget _buildRemovedThumbnail(
int item, BuildContext context, Animation<double> animation) {
return ProductThumbnail(animation, animation, _productWithId(item));
}
Widget _buildThumbnail(BuildContext context, int index, Animation<double> animation) {
Animation<double> thumbnailSize = Tween<double>(begin: 0.8, end: 1.0).animate(
Widget _buildThumbnail(
BuildContext context, int index, Animation<double> animation) {
Animation<double> thumbnailSize =
Tween<double>(begin: 0.8, end: 1.0).animate(
CurvedAnimation(
curve: Interval(0.33, 1.0, curve: Curves.easeIn),
parent: animation,
@ -468,7 +478,8 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
parent: animation,
);
return ProductThumbnail(thumbnailSize, opacity, _productWithId(_list[index]));
return ProductThumbnail(
thumbnailSize, opacity, _productWithId(_list[index]));
}
// If the lists are the same length, assume nothing has changed.
@ -476,7 +487,8 @@ class _ProductThumbnailRowState extends State<ProductThumbnailRow> {
// If the internalList is longer, then an item has been added.
void _updateLists() {
// Update _internalList based on the model
_internalList = ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList();
_internalList =
ScopedModel.of<AppStateModel>(context).productsInCart.keys.toList();
Set<int> internalSet = Set<int>.from(_internalList);
Set<int> listSet = Set<int>.from(_list.list);
@ -550,9 +562,11 @@ class ExtraProductsNumber extends StatelessWidget {
if (model.productsInCart.length > 3) {
int numOverflowProducts = _calculateOverflow(model);
// Maximum of 99 so padding doesn't get messy.
int displayedOverflowProducts = numOverflowProducts <= 99 ? numOverflowProducts : 99;
int displayedOverflowProducts =
numOverflowProducts <= 99 ? numOverflowProducts : 99;
return Container(
child: Text('+$displayedOverflowProducts',
child: Text(
'+$displayedOverflowProducts',
style: Theme.of(context).primaryTextTheme.button,
),
);
@ -637,7 +651,8 @@ class _ListModel {
void _removeAt(int index) {
final int removedItem = _items.removeAt(index);
if (removedItem != null) {
_animatedList.removeItem(index, (BuildContext context, Animation<double> animation) {
_animatedList.removeItem(index,
(BuildContext context, Animation<double> animation) {
return removedItemBuilder(removedItem, context, animation);
});
}

@ -24,7 +24,7 @@ import 'supplemental/asymmetric_view.dart';
class ProductPage extends StatelessWidget {
final Category category;
const ProductPage({this.category: Category.all});
const ProductPage({this.category = Category.all});
@override
Widget build(BuildContext context) {
@ -41,11 +41,8 @@ class HomePage extends StatelessWidget {
final ExpandingBottomSheet expandingBottomSheet;
final Backdrop backdrop;
const HomePage({
Key key,
this.expandingBottomSheet,
this.backdrop
}) : super(key: key);
const HomePage({Key key, this.expandingBottomSheet, this.backdrop})
: super(key: key);
@override
Widget build(BuildContext context) {

@ -63,8 +63,8 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
width: _leftColumnWidth,
child: IconButton(
icon: const Icon(Icons.keyboard_arrow_down),
onPressed: () => ExpandingBottomSheet.of(context).close()
),
onPressed: () =>
ExpandingBottomSheet.of(context).close()),
),
Text(
'CART',

@ -19,10 +19,10 @@ import 'package:flutter/widgets.dart';
class CutCornersBorder extends OutlineInputBorder {
const CutCornersBorder({
BorderSide borderSide: const BorderSide(),
BorderRadius borderRadius: const BorderRadius.all(Radius.circular(2.0)),
this.cut: 7.0,
double gapPadding: 2.0,
BorderSide borderSide = const BorderSide(),
BorderRadius borderRadius = const BorderRadius.all(Radius.circular(2.0)),
this.cut = 7.0,
double gapPadding = 2.0,
}) : super(
borderSide: borderSide,
borderRadius: borderRadius,
@ -104,8 +104,8 @@ class CutCornersBorder extends OutlineInputBorder {
Canvas canvas,
Rect rect, {
double gapStart,
double gapExtent: 0.0,
double gapPercentage: 0.0,
double gapExtent = 0.0,
double gapPercentage = 0.0,
TextDirection textDirection,
}) {
assert(gapExtent != null);

@ -20,7 +20,7 @@ import '../model/app_state_model.dart';
import '../model/product.dart';
class ProductCard extends StatelessWidget {
ProductCard({this.imageAspectRatio: 33 / 49, this.product})
ProductCard({this.imageAspectRatio = 33 / 49, this.product})
: assert(imageAspectRatio == null || imageAspectRatio > 0);
final double imageAspectRatio;

@ -14,7 +14,7 @@ import 'package:veggieseasons/widgets/veggie_card.dart';
class ListScreen extends StatelessWidget {
List<Widget> _generateVeggieRows(List<Veggie> veggies, Preferences prefs) {
final cards = new List<Widget>();
final cards = List<Widget>();
for (Veggie veggie in veggies) {
cards.add(Padding(

@ -118,7 +118,7 @@ abstract class Styles {
Season.autumn: Color(0xff724913),
};
static const seasonBorder = const Border(
static const seasonBorder = Border(
top: BorderSide(color: Color(0xff606060)),
left: BorderSide(color: Color(0xff606060)),
bottom: BorderSide(color: Color(0xff606060)),

@ -86,7 +86,7 @@ class CloseButton extends StatefulWidget {
@override
CloseButtonState createState() {
return new CloseButtonState();
return CloseButtonState();
}
}

@ -13,7 +13,7 @@ import 'package:veggieseasons/styles.dart';
//
// See https://github.com/flutter/flutter/projects/29 for more info.
typedef FutureOr<void> SettingsItemCallback();
typedef SettingsItemCallback = FutureOr<void> Function();
class SettingsNavigationIndicator extends StatelessWidget {
const SettingsNavigationIndicator({Key key}) : super(key: key);
@ -77,7 +77,7 @@ class SettingsItem extends StatefulWidget {
final SettingsItemCallback onPress;
@override
State<StatefulWidget> createState() => new SettingsItemState();
State<StatefulWidget> createState() => SettingsItemState();
}
class SettingsItemState extends State<SettingsItem> {

Loading…
Cancel
Save