Skip to content

Commit 0f51363

Browse files
Lesson 2: Planets-Flutter: creating a Planet card
1 parent 21d727a commit 0f51363

File tree

5 files changed

+66
-31
lines changed

5 files changed

+66
-31
lines changed

assets/img/mars.png

15.6 KB
Loading

lib/ui/home/home_page.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'home_page_body.dart';
23

34
class HomePage extends StatelessWidget {
45

@@ -8,6 +9,9 @@ class HomePage extends StatelessWidget {
89
body: new Column(
910
children: <Widget>[
1011
new GradientAppBar("treva"),
12+
new HomePageBody(),
13+
new HomePageBody(),
14+
new HomePageBody(),
1115
],
1216
),
1317
);

lib/ui/home/home_page_body.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import 'package:flutter/material.dart';
2+
import 'planet_row.dart';
3+
4+
class HomePageBody extends StatelessWidget {
5+
@override
6+
Widget build(BuildContext context) {
7+
return new PlanetRow();
8+
}
9+
}

lib/ui/home/planet_row.dart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import 'package:flutter/material.dart';
2+
3+
class PlanetRow extends StatelessWidget {
4+
5+
final planetThumbnail = new Container(
6+
margin: new EdgeInsets.symmetric(
7+
vertical: 16.0
8+
),
9+
alignment: FractionalOffset.centerLeft,
10+
child: new Image(
11+
image: new AssetImage("assets/img/mars.png"),
12+
height: 92.0,
13+
width: 92.0,
14+
),
15+
);
16+
17+
final planetCard = new Container(
18+
height: 124.0,
19+
margin: new EdgeInsets.only(left: 46.0),
20+
decoration: new BoxDecoration(
21+
color: new Color(0xFF333366),
22+
shape: BoxShape.rectangle,
23+
borderRadius: new BorderRadius.circular(8.0),
24+
boxShadow: <BoxShadow>[
25+
new BoxShadow(
26+
color: Colors.black12,
27+
blurRadius: 10.0,
28+
offset: new Offset(0.0, 10.0),
29+
),
30+
],
31+
),
32+
);
33+
34+
@override
35+
Widget build(BuildContext context) {
36+
return new Container(
37+
height: 120.0,
38+
margin: const EdgeInsets.symmetric(
39+
vertical: 16.0,
40+
horizontal: 24.0,
41+
),
42+
child: new Stack(
43+
children: <Widget>[
44+
planetCard,
45+
planetThumbnail,
46+
],
47+
)
48+
);
49+
}
50+
}

pubspec.yaml

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,10 @@ flutter:
2121
# the Icons class.
2222
uses-material-design: true
2323

24-
# To add assets to your application, add an assets section, like this:
25-
# assets:
26-
# - images/a_dot_burr.jpeg
27-
# - images/a_dot_ham.jpeg
28-
29-
# An image asset can refer to one or more resolution-specific "variants", see
30-
# https://flutter.io/assets-and-images/#resolution-aware.
31-
32-
# For details regarding adding assets from package dependencies, see
33-
# https://flutter.io/assets-and-images/#from-packages
34-
35-
# To add custom fonts to your application, add a fonts section here,
36-
# in this "flutter" section. Each entry in this list should have a
37-
# "family" key with the font family name, and a "fonts" key with a
38-
# list giving the asset and other descriptors for the font. For
39-
# example:
40-
# fonts:
41-
# - family: Schyler
42-
# fonts:
43-
# - asset: fonts/Schyler-Regular.ttf
44-
# - asset: fonts/Schyler-Italic.ttf
45-
# style: italic
46-
# - family: Trajan Pro
47-
# fonts:
48-
# - asset: fonts/TrajanPro.ttf
49-
# - asset: fonts/TrajanPro_Bold.ttf
50-
# weight: 700
51-
#
52-
# For details regarding fonts from package dependencies,
53-
# see https://flutter.io/custom-fonts/#from-packages
5424
fonts:
5525
- family: Poppins
5626
fonts:
5727
- asset: assets/fonts/Poppins-SemiBold.ttf
58-
weight: 600
28+
weight: 600
29+
assets:
30+
- assets/img/mars.png

0 commit comments

Comments
 (0)