1
0
mirror of https://github.com/flutter/samples.git synced 2026-06-08 15:28:30 +00:00

Analysis options, fixes, and formatting (#110)

This commit is contained in:
Brett Morgan
2019-07-04 15:41:59 +10:00
committed by GitHub
parent d4997f6562
commit 90ecd8df25
11 changed files with 90 additions and 53 deletions

View File

@@ -72,7 +72,7 @@ Route<dynamic> _getRoute(RouteSettings settings) {
return MaterialPageRoute<void>(
settings: settings,
builder: (BuildContext context) => LoginPage(),
builder: (context) => LoginPage(),
fullscreenDialog: true,
);
}

View File

@@ -60,7 +60,7 @@ class _FrontLayer extends StatelessWidget {
}
class _BackdropTitle extends AnimatedWidget {
final Function onPress;
final VoidCallback onPress;
final Widget frontTitle;
final Widget backTitle;
@@ -77,7 +77,7 @@ class _BackdropTitle extends AnimatedWidget {
@override
Widget build(BuildContext context) {
final Animation<double> animation = CurvedAnimation(
parent: this.listenable,
parent: this.listenable as Animation<double>,
curve: Interval(0.0, 0.78),
);
@@ -212,7 +212,7 @@ class _BackdropState extends State<Backdrop>
Curve secondCurve; // Curve for second TweenSequenceItem
double firstWeight; // Weight of first TweenSequenceItem
double secondWeight; // Weight of second TweenSequenceItem
Animation animation; // Animation on which TweenSequence runs
Animation<double> animation; // Animation on which TweenSequence runs
if (_frontLayerVisible) {
firstCurve = _kAccelerateCurve;
@@ -305,18 +305,18 @@ class _BackdropState extends State<Backdrop>
IconButton(
icon: const Icon(Icons.search, semanticLabel: 'login'),
onPressed: () {
Navigator.push(
Navigator.push<void>(
context,
MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
MaterialPageRoute(builder: (context) => LoginPage()),
);
},
),
IconButton(
icon: const Icon(Icons.tune, semanticLabel: 'login'),
onPressed: () {
Navigator.push(
Navigator.push<void>(
context,
MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
MaterialPageRoute(builder: (context) => LoginPage()),
);
},
),

View File

@@ -75,9 +75,8 @@ class CategoryMenuPage extends StatelessWidget {
padding: EdgeInsets.only(top: 40.0),
color: kShrinePink100,
child: ListView(
children: _categories
.map((Category c) => _buildCategory(c, context))
.toList()),
children: _categories.map((c) => _buildCategory(c, context)).toList(),
),
),
);
}

View File

@@ -51,8 +51,9 @@ class ExpandingBottomSheet extends StatefulWidget {
{bool isNullOk = false}) {
assert(isNullOk != null);
assert(context != null);
final _ExpandingBottomSheetState result = context
.ancestorStateOfType(const TypeMatcher<_ExpandingBottomSheetState>());
final _ExpandingBottomSheetState result = context.ancestorStateOfType(
const TypeMatcher<_ExpandingBottomSheetState>())
as _ExpandingBottomSheetState;
if (isNullOk || result != null) {
return result;
}
@@ -71,7 +72,7 @@ Animation<T> _getEmphasizedEasingAnimation<T>(
@required T peak,
@required T end,
@required bool isForward,
@required Animation parent}) {
@required Animation<double> parent}) {
Curve firstCurve;
Curve secondCurve;
double firstWeight;
@@ -616,6 +617,9 @@ class ProductThumbnail extends StatelessWidget {
}
}
typedef RemovedItemBuilder = Widget Function(
int, BuildContext, Animation<double>);
// _ListModel manipulates an internal list and an AnimatedList
class _ListModel {
_ListModel(
@@ -627,7 +631,7 @@ class _ListModel {
_items = List<int>.from(initialItems ?? <int>[]);
final GlobalKey<AnimatedListState> listKey;
final dynamic removedItemBuilder;
final RemovedItemBuilder removedItemBuilder;
final List<int> _items;
AnimatedListState get _animatedList => listKey.currentState;
@@ -651,8 +655,7 @@ 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, (context, animation) {
return removedItemBuilder(removedItem, context, animation);
});
}

View File

@@ -29,7 +29,7 @@ class ProductPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget child, AppStateModel model) {
builder: (context, child, model) {
return AsymmetricView(
products: model.getProducts(),
);

View File

@@ -287,7 +287,7 @@ class ProductsRepository {
if (category == Category.all) {
return allProducts;
} else {
return allProducts.where((Product p) => p.category == category).toList();
return allProducts.where((p) => p.category == category).toList();
}
}
}

View File

@@ -35,7 +35,7 @@ class AsymmetricView extends StatelessWidget {
/// some kinda awkward math so we use _evenCasesIndex and _oddCasesIndex as
/// helpers for creating the index of the product list that will correspond
/// to the index of the list of columns.
return List.generate(_listItemCount(products.length), (int index) {
return List.generate(_listItemCount(products.length), (index) {
double width = .59 * MediaQuery.of(context).size.width;
Widget column;
if (index % 2 == 0) {

View File

@@ -28,40 +28,42 @@ class TwoProductCardColumn extends StatelessWidget {
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
const spacerHeight = 44.0;
builder: (context, constraints) {
const spacerHeight = 44.0;
double heightOfCards = (constraints.biggest.height - spacerHeight) / 2.0;
double heightOfImages = heightOfCards - ProductCard.kTextBoxHeight;
double imageAspectRatio =
(heightOfImages >= 0.0 && constraints.biggest.width > heightOfImages)
? constraints.biggest.width / heightOfImages
: 33 / 49;
double heightOfCards =
(constraints.biggest.height - spacerHeight) / 2.0;
double heightOfImages = heightOfCards - ProductCard.kTextBoxHeight;
double imageAspectRatio = (heightOfImages >= 0.0 &&
constraints.biggest.width > heightOfImages)
? constraints.biggest.width / heightOfImages
: 33 / 49;
return ListView(
children: <Widget>[
Padding(
padding: EdgeInsetsDirectional.only(start: 28.0),
child: top != null
? ProductCard(
imageAspectRatio: imageAspectRatio,
product: top,
)
: SizedBox(
height: heightOfCards > 0 ? heightOfCards : spacerHeight,
),
),
SizedBox(height: spacerHeight),
Padding(
padding: EdgeInsetsDirectional.only(end: 28.0),
child: ProductCard(
imageAspectRatio: imageAspectRatio,
product: bottom,
return ListView(
children: <Widget>[
Padding(
padding: EdgeInsetsDirectional.only(start: 28.0),
child: top != null
? ProductCard(
imageAspectRatio: imageAspectRatio,
product: top,
)
: SizedBox(
height: heightOfCards > 0 ? heightOfCards : spacerHeight,
),
),
),
],
);
});
SizedBox(height: spacerHeight),
Padding(
padding: EdgeInsetsDirectional.only(end: 28.0),
child: ProductCard(
imageAspectRatio: imageAspectRatio,
product: bottom,
),
),
],
);
},
);
}
}