Skip to content

Commit 863ee96

Browse files
background image
1 parent 568703e commit 863ee96

2 files changed

Lines changed: 29 additions & 13 deletions

File tree

lib/model/planets.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ class Planet {
66
final String gravity;
77
final String description;
88
final String image;
9+
final String picture;
910

1011
const Planet({this.id, this.name, this.location, this.distance, this.gravity,
11-
this.description, this.image});
12+
this.description, this.image, this.picture});
1213
}
1314

1415
List<Planet> planets = [
@@ -20,6 +21,7 @@ List<Planet> planets = [
2021
gravity: "3.711 m/s ",
2122
description: "Lorem ipsum...",
2223
image: "assets/img/mars.png",
24+
picture: "https://www.nasa.gov/sites/default/files/thumbnails/image/pia21723-16.jpg"
2325
),
2426
const Planet(
2527
id: "2",
@@ -29,6 +31,7 @@ List<Planet> planets = [
2931
gravity: "3.711 m/s ",
3032
description: "Lorem ipsum...",
3133
image: "assets/img/neptune.png",
34+
picture: "https://www.nasa.gov/sites/default/files/styles/full_width_feature/public/images/110411main_Voyager2_280_yshires.jpg"
3235
),
3336
const Planet(
3437
id: "3",
@@ -38,6 +41,7 @@ List<Planet> planets = [
3841
gravity: "3.711 m/s ",
3942
description: "Lorem ipsum...",
4043
image: "assets/img/moon.png",
44+
picture: "https://farm5.staticflickr.com/4086/5052125139_43c31b7012.jpg"
4145
),
4246
const Planet(
4347
id: "4",
@@ -47,6 +51,7 @@ List<Planet> planets = [
4751
gravity: "3.711 m/s ",
4852
description: "Lorem ipsum...",
4953
image: "assets/img/earth.png",
54+
picture: "https://www.nasa.gov/sites/default/files/styles/full_width_feature/public/thumbnails/image/iss042e340851_1.jpg"
5055
),
5156
const Planet(
5257
id: "5",
@@ -56,5 +61,6 @@ List<Planet> planets = [
5661
gravity: "3.711 m/s ",
5762
description: "Lorem ipsum...",
5863
image: "assets/img/mercury.png",
64+
picture: "https://c1.staticflickr.com/9/8105/8497927473_2845ae671e_b.jpg"
5965
),
6066
];

lib/ui/detail/detail_page.dart

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_planets_tutorial/model/planets.dart';
3-
import 'package:flutter_planets_tutorial/ui/text_style.dart';
43

54

65
class DetailPage extends StatelessWidget {
@@ -11,22 +10,33 @@ class DetailPage extends StatelessWidget {
1110

1211
@override
1312
Widget build(BuildContext context) {
13+
print(planet.picture);
1414
return new Scaffold(
1515
body: new Container(
16-
color: const Color(0xFF736AB7),
1716
constraints: new BoxConstraints.expand(),
18-
child: new Column(
19-
mainAxisAlignment: MainAxisAlignment.center,
17+
color: new Color(0xFF736AB7),
18+
child: new Stack (
2019
children: <Widget>[
21-
new Text(
22-
planet.name,
23-
style: Style.headerTextStyle,
20+
new Container(
21+
child: new Image.network(planet.picture,
22+
fit: BoxFit.cover,
23+
height: 300.0,
24+
),
25+
constraints: new BoxConstraints.expand(height: 295.0),
2426
),
25-
new Hero(tag: "planet-hero-${planet.id}",
26-
child: new Image.asset(
27-
planet.image,
28-
width: 96.0,
29-
height: 96.0,
27+
new Container(
28+
margin: new EdgeInsets.only(top: 190.0),
29+
height: 110.0,
30+
decoration: new BoxDecoration(
31+
gradient: new LinearGradient(
32+
colors: <Color>[
33+
new Color(0x00736AB7),
34+
new Color(0xFF736AB7)
35+
],
36+
stops: [0.0, 0.9],
37+
begin: const FractionalOffset(0.0, 0.0),
38+
end: const FractionalOffset(0.0, 1.0),
39+
),
3040
),
3141
)
3242
],

0 commit comments

Comments
 (0)