1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +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

@@ -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,
),
),
],
);
},
);
}
}