Skip to content

Commit cc51efa

Browse files
committed
Added list layout
1 parent 87df16a commit cc51efa

File tree

3 files changed

+74
-3
lines changed

3 files changed

+74
-3
lines changed

movie_app/lib/main.dart

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'movie_detail_page.dart';
3+
import 'package:flutter/foundation.dart';
34

45
void main() => runApp(new MyApp());
56

@@ -9,6 +10,8 @@ class MyApp extends StatelessWidget{
910
@override
1011
Widget build(BuildContext context) {
1112

13+
debugPrint("Calling now");
14+
1215
return new MaterialApp(
1316

1417
title: 'Movie-detail-page' ,

movie_app/lib/movie_detail_page.dart

+69-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'dart:async';
33
import 'dart:convert';
44
import 'package:http/http.dart' as http;
5+
import 'package:flutter/foundation.dart';
56

67

78
class MovieList extends StatefulWidget{
@@ -28,6 +29,9 @@ class MovieListState extends State<MovieList>{
2829

2930
setState(() {
3031
movies = data['results'];
32+
33+
debugPrint('Response $movies');
34+
3135
});
3236

3337
}
@@ -36,6 +40,8 @@ class MovieListState extends State<MovieList>{
3640
@override
3741
Widget build(BuildContext context) {
3842

43+
getData();
44+
3945
return new Scaffold(
4046

4147
backgroundColor: Colors.white,
@@ -64,6 +70,7 @@ class MovieListState extends State<MovieList>{
6470
crossAxisAlignment: CrossAxisAlignment.start,
6571
children: <Widget>[
6672
new MovieTitle(mainColor),
73+
6774
],
6875
),
6976

@@ -77,7 +84,7 @@ class MovieListState extends State<MovieList>{
7784

7885
Future<Map> getJson() async {
7986

80-
var url = 'http://api.themoviedb.org/3/discover/movie?api_key={1e180262302e279996c7e928084a6c28}';
87+
var url = 'http://api.themoviedb.org/3/discover/movie?api_key=1e180262302e279996c7e928084a6c28';
8188
http.Response response = await http.get(url);
8289
return json.decode(response.body);
8390

@@ -115,4 +122,64 @@ class MovieTitle extends StatelessWidget{
115122
}
116123

117124

118-
}
125+
}
126+
127+
128+
class MovieCell extends StatelessWidget{
129+
130+
final movies;
131+
final i;
132+
Color mainColor = const Color(0xff3C3261);
133+
var image_url = 'https://image.tmdb.org/t/p/w500/';
134+
135+
MovieCell(this.movies, this.i);
136+
137+
138+
@override
139+
Widget build(BuildContext context) {
140+
141+
return new Column(
142+
143+
children: <Widget>[
144+
new Row(
145+
children: <Widget>[
146+
new Padding(
147+
padding: const EdgeInsets.all(0.0),
148+
child: new Container(
149+
margin: const EdgeInsets.all(0.0),
150+
child: new Container(
151+
margin: const EdgeInsets.all(0.0),
152+
child: new Container(
153+
width: 70.0,
154+
height: 70.0,
155+
),
156+
),
157+
decoration: new BoxDecoration(
158+
borderRadius: new BorderRadius.circular(10.0),
159+
color: Colors.grey,
160+
image: new DecorationImage(image: new NetworkImage(image_url+movies[i]),fit: BoxFit.cover),
161+
boxShadow: [
162+
new BoxShadow(
163+
color: mainColor,
164+
blurRadius: 5.0,
165+
offset: new Offset(2.0,5.0)
166+
)
167+
],
168+
),
169+
),
170+
171+
)
172+
],
173+
)
174+
175+
],
176+
177+
);
178+
}
179+
180+
181+
182+
183+
184+
185+
}

movie_app/pubspec.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ environment:
1919
dependencies:
2020
flutter:
2121
sdk: flutter
22+
http: ^0.12.0+2
2223

2324
# The following adds the Cupertino Icons font to your application.
2425
# Use with the CupertinoIcons class for iOS style icons.
2526
cupertino_icons: ^0.1.2
26-
http: ^0.12.0+2
27+
2728

2829

2930
dev_dependencies:

0 commit comments

Comments
 (0)