Skip to content

Commit 1ed26aa

Browse files
willlarchetianlunlee
authored andcommitted
[102] Completed code.
[101] Starter code. [101] Making AppBar something you add in 102. [Model] Adding model from the start. [103] Adding fonts. [103] Supplemental files. [101] Correcting supplemental files. [101] Copy correction. [101] Minor renaming. [101] Update for Dart 2. [101] Missing dependency. [101] Dart 2. [101] Dart 2. [101] Dart 2. [101] Dart 2. [101] Correcting model. [Meta] README file. [Meta] Clarification. [101] Copy correction. [104] Updating data. [101] Correcting widget class. (#23) Add link to actual codelab in the README [Meta] README correction. [101] README specificity. [101] Complete code. [102] Starter code. [102] Minor copy correction. [101] Update for Dart 2 [102] Rebase. Add the slanted_menu.png to assets for 101 branch so its ready when needed. (#44) (#45) [102] Complete code. [103] Starter code. [102] Correcting home being stateful. [103] Correcting order of fields. (#10) [102] Removing unneeded value. [102] Dart 2. [102] Data correction. [103] README specificity. [META] Readme correction.
1 parent 574253b commit 1ed26aa

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

mdc_100_series/lib/home.dart

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,69 @@
1313
// limitations under the License.
1414

1515
import 'package:flutter/material.dart';
16+
import 'package:intl/intl.dart';
17+
18+
import 'model/data.dart';
19+
import 'model/product.dart';
1620

1721
import 'model/data.dart';
1822
import 'model/product.dart';
1923
import 'supplemental/asymmetric_view.dart';
2024

2125
class HomePage extends StatelessWidget {
26+
27+
List<Card> _buildGridCards(BuildContext context) {
28+
List<Product> products = getProducts(Category.all);
29+
30+
if (products == null || products.isEmpty) {
31+
return const <Card>[];
32+
}
33+
34+
final ThemeData theme = Theme.of(context);
35+
final NumberFormat formatter = NumberFormat.simpleCurrency(
36+
locale: Localizations.localeOf(context).toString());
37+
38+
return products.map((product) {
39+
return Card(
40+
child: Column(
41+
crossAxisAlignment: CrossAxisAlignment.start,
42+
children: <Widget>[
43+
AspectRatio(
44+
aspectRatio: 18 / 11,
45+
child: Image.asset(
46+
product.assetName,
47+
package: product.assetPackage,
48+
fit: BoxFit.fitWidth,
49+
),
50+
),
51+
Expanded(
52+
child: Padding(
53+
padding: EdgeInsets.fromLTRB(16.0, 12.0, 16.0, 8.0),
54+
child: Column(
55+
crossAxisAlignment: CrossAxisAlignment.start,
56+
children: <Widget>[
57+
// TODO(larche): Make headline6 when available
58+
Text(
59+
product.name,
60+
style: theme.textTheme.title,
61+
maxLines: 1,
62+
),
63+
SizedBox(height: 8.0),
64+
// TODO(larche): Make subtitle2 when available
65+
Text(
66+
formatter.format(product.price),
67+
style: theme.textTheme.body2,
68+
),
69+
],
70+
),
71+
),
72+
),
73+
],
74+
),
75+
);
76+
}).toList();
77+
}
78+
2279
@override
2380
Widget build(BuildContext context) {
2481
return Scaffold(

0 commit comments

Comments
 (0)