SlideShare a Scribd company logo
Project 1
Movie Apps
Pendahuluan
pada project 1 kali ini kita akan belajar bagaimana membuat movie apps sederhana
dengan menggunakan flutter, yang paling utama terlebih dahulu sudah mempunyai
akses API di website resmi https://www.themoviedb.org/?_dc=1586104474 karena kita akan
mengambil data berdasarkan API yang ada di web tersebut.
themoviedb.org
untuk mendapatkan API dari https://www.themoviedb.org/?_dc=1586104474m dan bagaimana cara
mengaksesnya bisa di baca link ini https://www.dicoding.com/blog/registrasi-testing-themoviedb-
api/ dengan mengikuti tutorial sederhana ini penulis mengharapkan pembaca dapat memahami
pemrograman flutter dan dapat dikembangkan menjadi lebih sempurna lagi.
New Project Flutter
ikuti langkah langkah berikut untuk dapat memulai project movie apps, pastikan sudah terinstall
flutter dan plugin flutter di pc maupun android studio.
Tampilan Awal Android Studio
Klik new flutter project
Ketikkan nama aplikasi
Klik Finish
siapkan library untuk request API http
buka situs resminya https://pub.dev/
lalu ketikkan library http di column search, buka tab installing copy http: ^0.12.0.4, kedalam
file flutter pubspec.yaml
name: fluttermovie
description: A new Flutter application.
# The following defines the version and build number for your
application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number
used as versionCode.
# Read more about Android versioning at https://developer.android.com/
studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while
build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/
Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
http: ^0.12.0+4
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like
this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific
"variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
lalu klik Pub Get(Android Studio) klik kanan Get Packages (Visual Code)
Ketikkan code di lib/main.dart
import 'package:flutter/material.dart';
import 'movie_list.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
//Import movielist class
home: new MovieList(),
);
}
}
Lalu Buat file baru lib/config.dart
//API KEY
String getApiKey() {
return '6a5b06b76d2c628e345f4730e4473751';
}
File baru lib/movielist.dart
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
import 'movie_detail.dart';
import 'config.dart';
class MovieList extends StatefulWidget {
@override
MovieListState createState() {
return new MovieListState();
}
}
class MovieListState extends State<MovieList> {
var movies;
Color mainColor = const Color(0xff3C3261);
void getData() async {
var data = await getJson();
setState(() {
movies = data['results'];
});
}
@override
Widget build(BuildContext context) {
getData();
return new Scaffold(
backgroundColor: Colors.white,
appBar: new AppBar(
elevation: 0.3,
centerTitle: true,
backgroundColor: Colors.white,
leading: new Icon(
Icons.arrow_back,
color: mainColor,
),
title: new Text(
'Movies',
style: new TextStyle(
color: mainColor,
fontFamily: 'Arvo',
fontWeight: FontWeight.bold),
),
actions: <Widget>[
new Icon(
Icons.menu,
color: mainColor,
)
],
),
body: new Padding(
padding: const EdgeInsets.all(16.0),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new MovieTitle(mainColor),
new Expanded(
child: new ListView.builder(
itemCount: movies == null ? 0 : movies.length,
itemBuilder: (context, i) {
return new FlatButton(
child: new MovieCell(movies, i),
padding: const EdgeInsets.all(0.0),
onPressed: () {
Navigator.push(context,
new MaterialPageRoute(builder: (context) {
return new MovieDetail(movies[i]);
}));
},
color: Colors.white,
);
}),
)
],
),
),
);
}
}
Future<Map> getJson() async {
var apiKey = getApiKey();
var url = 'http://api.themoviedb.org/3/discover/movie?api_key=$
{apiKey}';
var response = await http.get(url);
return json.decode(response.body);
}
class MovieTitle extends StatelessWidget {
final Color mainColor;
MovieTitle(this.mainColor);
@override
Widget build(BuildContext context) {
return new Padding(
padding: const EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 16.0),
child: new Text(
'Top Rated',
style: new TextStyle(
fontSize: 40.0,
color: mainColor,
fontWeight: FontWeight.bold,
fontFamily: 'Arvo'),
textAlign: TextAlign.left,
),
);
}
}
class MovieCell extends StatelessWidget {
final movies;
final i;
Color mainColor = const Color(0xff3C3261);
var image_url = 'https://image.tmdb.org/t/p/w500/';
MovieCell(this.movies, this.i);
@override
Widget build(BuildContext context) {
return new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(0.0),
child: new Container(
margin: const EdgeInsets.all(16.0),
// child: new
Image.network(image_url+movies[i]['poster_path'],width: 100.0,height:
100.0),
child: new Container(
width: 70.0,
height: 70.0,
),
decoration: new BoxDecoration(
borderRadius: new BorderRadius.circular(10.0),
color: Colors.grey,
image: new DecorationImage(
image: new NetworkImage(
image_url + movies[i]['poster_path']),
fit: BoxFit.cover),
boxShadow: [
new BoxShadow(
color: mainColor,
blurRadius: 5.0,
offset: new Offset(2.0, 5.0))
],
),
),
),
new Expanded(
child: new Container(
margin: const EdgeInsets.fromLTRB(16.0, 0.0, 16.0,
0.0),
child: new Column(
children: [
new Text(
movies[i]['title'],
style: new TextStyle(
fontSize: 20.0,
fontFamily: 'Arvo',
fontWeight: FontWeight.bold,
color: mainColor),
),
new Padding(padding: const EdgeInsets.all(2.0)),
new Text(
movies[i]['overview'],
maxLines: 3,
style: new TextStyle(
color: const Color(0xff8785A4), fontFamily:
'Arvo'),
)
],
crossAxisAlignment: CrossAxisAlignment.start,
),
)),
],
),
new Container(
width: 300.0,
height: 0.5,
color: const Color(0xD2D2E1ff),
margin: const EdgeInsets.all(16.0),
)
],
);
}
}
lalu yang terakhit buat file baru dengan di dalam lib/movie_detail.dart
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
class MovieDetail extends StatelessWidget {
final movie;
var image_url = 'https://image.tmdb.org/t/p/w500/';
MovieDetail(this.movie);
Color mainColor = const Color(0xff3C3261);
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Stack(fit: StackFit.expand, children: [
new Image.network(
image_url + movie['poster_path'],
fit: BoxFit.cover,
),
new BackdropFilter(
filter: new ui.ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
child: new Container(
color: Colors.black.withOpacity(0.5),
),
),
new SingleChildScrollView(
child: new Container(
margin: const EdgeInsets.all(20.0),
child: new Column(
children: <Widget>[
new Container(
alignment: Alignment.center,
child: new Container(
width: 400.0,
height: 400.0,
),
decoration: new BoxDecoration(
borderRadius: new BorderRadius.circular(10.0),
image: new DecorationImage(
image: new NetworkImage(
image_url + movie['poster_path']),
fit: BoxFit.cover),
boxShadow: [
new BoxShadow(
color: Colors.black,
blurRadius: 20.0,
offset: new Offset(0.0, 10.0))
]),
),
new Container(
margin: const EdgeInsets.symmetric(
vertical: 20.0, horizontal: 0.0),
child: new Row(
children: <Widget>[
new Expanded(
child: new Text(
movie['title'],
style: new TextStyle(
color: Colors.white,
fontSize: 30.0,
fontFamily: 'Arvo'),
)),
new Text(
'${movie['vote_average']}/10',
style: new TextStyle(
color: Colors.white,
fontSize: 20.0,
fontFamily: 'Arvo'),
)
],
),
),
new Text(movie['overview'],style: new TextStyle(color:
Colors.white, fontFamily: 'Arvo')),
new Padding(padding: const EdgeInsets.all(10.0)),
new Row(
children: <Widget>[
new Expanded(
child: new Container(
width: 150.0,
height: 60.0,
alignment: Alignment.center,
child: new Text(
'Rate Movie',
style: new TextStyle(
color: Colors.white,
fontFamily: 'Arvo',
fontSize: 20.0),
),
decoration: new BoxDecoration(
borderRadius: new
BorderRadius.circular(10.0),
color: const Color(0xaa3C3261)),
)),
new Padding(
padding: const EdgeInsets.all(16.0),
child: new Container(
padding: const EdgeInsets.all(16.0),
alignment: Alignment.center,
child: new Icon(
Icons.share,
color: Colors.white,
),
decoration: new BoxDecoration(
borderRadius: new BorderRadius.circular(10.0),
color: const Color(0xaa3C3261)),
),
),
new Padding(
padding: const EdgeInsets.all(8.0),
child: new Container(
padding: const EdgeInsets.all(16.0),
alignment: Alignment.center,
child: new Icon(
Icons.bookmark,
color: Colors.white,
),
decoration: new BoxDecoration(
borderRadius: new
BorderRadius.circular(10.0),
color: const Color(0xaa3C3261)),
)
),
],
)
],
),
),
)
]),
);
}
}
Outputnya :
versi Mobile
Versi Web
Flutter movie apps tutor

More Related Content

PPTX
Topologi Jaringan Kelas XI.pptx
PPTX
Insertion sort
DOCX
Sejarah singkat monumen nasional
PPTX
KWH METER PRABAYAR CSI11.pptx
PDF
Laporan Laboratorium Dasar Pemrograman dengan Bahasa C by Muhammad Kennedy Gi...
PDF
Konfigurasi Routing OSPF Di MikroTik
PPT
Materi Struktur Data Tree
Topologi Jaringan Kelas XI.pptx
Insertion sort
Sejarah singkat monumen nasional
KWH METER PRABAYAR CSI11.pptx
Laporan Laboratorium Dasar Pemrograman dengan Bahasa C by Muhammad Kennedy Gi...
Konfigurasi Routing OSPF Di MikroTik
Materi Struktur Data Tree

What's hot (20)

PDF
PPT
Penyederhanaan Karnaugh Map
PPTX
Jaringan komputer subneting
PPTX
Dasar Telekomunikasi - Slide week 3 informasi
PPT
9.algoritma kriptografi klasik (bag 5)xx
PPTX
Presentasi festival di jepang bulan juli-agustus
PPT
Pertemuan 3 - Digital Image Processing - Spatial Filtering - Citra Digital
PPTX
PDF
Laporan praktikum jarkom_3
PDF
tugas contoh proposal lomba
PPT
Perawatan jaringan.ppt
PPTX
HALF AND FULL SUBTRACTOR
PPTX
Pertemuan 6 Penyederhanaan RL-Karnaugh Map
DOCX
Tugas topologi jaringan
PPT
Sistem Kendali.ppt
DOCX
Ampar
DOCX
SALURAN TRANSMISI [Praktikum DST]
PPTX
Cara Install Aplikasi pada OS Windows XP di VirtualBox
DOC
Band pass filter
PPTX
Pengolahan Sinyal Digital - Slide week 2 - sistem & sinyal waktu diskrit
Penyederhanaan Karnaugh Map
Jaringan komputer subneting
Dasar Telekomunikasi - Slide week 3 informasi
9.algoritma kriptografi klasik (bag 5)xx
Presentasi festival di jepang bulan juli-agustus
Pertemuan 3 - Digital Image Processing - Spatial Filtering - Citra Digital
Laporan praktikum jarkom_3
tugas contoh proposal lomba
Perawatan jaringan.ppt
HALF AND FULL SUBTRACTOR
Pertemuan 6 Penyederhanaan RL-Karnaugh Map
Tugas topologi jaringan
Sistem Kendali.ppt
Ampar
SALURAN TRANSMISI [Praktikum DST]
Cara Install Aplikasi pada OS Windows XP di VirtualBox
Band pass filter
Pengolahan Sinyal Digital - Slide week 2 - sistem & sinyal waktu diskrit
Ad

Similar to Flutter movie apps tutor (20)

PDF
Download and restrict video files in android app
PDF
Usage Note of SWIG for PHP
PDF
Build a video chat application with twilio, rails, and javascript (part 1)
PPTX
[Devoxx Morocco 2015] Apache Cordova In Action
PDF
Appcelerator Titanium Kinetic practices part 1
PDF
Lessons from a year of building apps with React Native
PDF
Crud operations using aws dynamo db with flask ap is and boto3
PDF
create-netflix-clone-06-client-ui_transcript.pdf
PPTX
pebble - Building apps on pebble
PDF
Browser Extensions for Web Hackers
PPT
Android Studio Software Installation steps in windows.
PPTX
Titanium Appcelerator - Beginners
PPTX
Keynote + Next Gen UIs.pptx
PPT
How to implement camera recording for USB webcam or IP camera in C#.NET
ODP
Best practices in WordPress Development
PDF
Firefox OS workshop, Colombia
PDF
Cloud Messaging Flutter
PPT
Setting up the hyperledger composer in ubuntu
PPTX
Application Programming and continuing.pptx
PDF
Androidreadme
Download and restrict video files in android app
Usage Note of SWIG for PHP
Build a video chat application with twilio, rails, and javascript (part 1)
[Devoxx Morocco 2015] Apache Cordova In Action
Appcelerator Titanium Kinetic practices part 1
Lessons from a year of building apps with React Native
Crud operations using aws dynamo db with flask ap is and boto3
create-netflix-clone-06-client-ui_transcript.pdf
pebble - Building apps on pebble
Browser Extensions for Web Hackers
Android Studio Software Installation steps in windows.
Titanium Appcelerator - Beginners
Keynote + Next Gen UIs.pptx
How to implement camera recording for USB webcam or IP camera in C#.NET
Best practices in WordPress Development
Firefox OS workshop, Colombia
Cloud Messaging Flutter
Setting up the hyperledger composer in ubuntu
Application Programming and continuing.pptx
Androidreadme
Ad

More from Herry Prasetyo (20)

PDF
Matematika Kelas 1 SD Hanya untuk kepentingan pribadi
PDF
Pemrograman Dasar Python Dari Dasar Sampai bisa
PDF
Modul AJar Rekayasa Perangkat Lunak 2024
PPTX
Luring DI Makasar pelatihan mobile pptx
PDF
"Web Development - Inovasi Digital 2024"
PDF
Head first laravel
PDF
Modul Laravel
PDF
Modul Ajar Basis Data
PDF
WAWASAN KEBANGSAAN DAN NILAI NILAI BELA NEGARA
PDF
MODUL KEDUA.pdf
PDF
Modul Pertama.pdf
PDF
PDF
Sertifikat Dicoding
PDF
LatihanSederhanaAJA
PDF
Tutorial basicapp
PDF
Laravel[part ii]
PDF
Laravel[part 1]
PPTX
PPT
Konversi sistem bilangan
PDF
Mengamankan jaringan wifi
Matematika Kelas 1 SD Hanya untuk kepentingan pribadi
Pemrograman Dasar Python Dari Dasar Sampai bisa
Modul AJar Rekayasa Perangkat Lunak 2024
Luring DI Makasar pelatihan mobile pptx
"Web Development - Inovasi Digital 2024"
Head first laravel
Modul Laravel
Modul Ajar Basis Data
WAWASAN KEBANGSAAN DAN NILAI NILAI BELA NEGARA
MODUL KEDUA.pdf
Modul Pertama.pdf
Sertifikat Dicoding
LatihanSederhanaAJA
Tutorial basicapp
Laravel[part ii]
Laravel[part 1]
Konversi sistem bilangan
Mengamankan jaringan wifi

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
cuic standard and advanced reporting.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Empathic Computing: Creating Shared Understanding
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Big Data Technologies - Introduction.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
cuic standard and advanced reporting.pdf
Unlocking AI with Model Context Protocol (MCP)
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
Assigned Numbers - 2025 - Bluetooth® Document
“AI and Expert System Decision Support & Business Intelligence Systems”
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Big Data Technologies - Introduction.pptx

Flutter movie apps tutor

  • 1. Project 1 Movie Apps Pendahuluan pada project 1 kali ini kita akan belajar bagaimana membuat movie apps sederhana dengan menggunakan flutter, yang paling utama terlebih dahulu sudah mempunyai akses API di website resmi https://www.themoviedb.org/?_dc=1586104474 karena kita akan mengambil data berdasarkan API yang ada di web tersebut. themoviedb.org untuk mendapatkan API dari https://www.themoviedb.org/?_dc=1586104474m dan bagaimana cara mengaksesnya bisa di baca link ini https://www.dicoding.com/blog/registrasi-testing-themoviedb- api/ dengan mengikuti tutorial sederhana ini penulis mengharapkan pembaca dapat memahami pemrograman flutter dan dapat dikembangkan menjadi lebih sempurna lagi.
  • 2. New Project Flutter ikuti langkah langkah berikut untuk dapat memulai project movie apps, pastikan sudah terinstall flutter dan plugin flutter di pc maupun android studio. Tampilan Awal Android Studio Klik new flutter project
  • 3. Ketikkan nama aplikasi Klik Finish siapkan library untuk request API http buka situs resminya https://pub.dev/
  • 4. lalu ketikkan library http di column search, buka tab installing copy http: ^0.12.0.4, kedalam file flutter pubspec.yaml name: fluttermovie description: A new Flutter application. # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/ studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/ Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.3 http: ^0.12.0+4 dev_dependencies: flutter_test:
  • 5. sdk: flutter # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware. # For details regarding adding assets from package dependencies, see # https://flutter.dev/assets-and-images/#from-packages # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a # "family" key with the font family name, and a "fonts" key with a # list giving the asset and other descriptors for the font. For # example: # fonts: # - family: Schyler # fonts: # - asset: fonts/Schyler-Regular.ttf # - asset: fonts/Schyler-Italic.ttf # style: italic # - family: Trajan Pro # fonts: # - asset: fonts/TrajanPro.ttf # - asset: fonts/TrajanPro_Bold.ttf # weight: 700 # # For details regarding fonts from package dependencies, # see https://flutter.dev/custom-fonts/#from-packages lalu klik Pub Get(Android Studio) klik kanan Get Packages (Visual Code) Ketikkan code di lib/main.dart import 'package:flutter/material.dart'; import 'movie_list.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter Demo',
  • 6. //Import movielist class home: new MovieList(), ); } } Lalu Buat file baru lib/config.dart //API KEY String getApiKey() { return '6a5b06b76d2c628e345f4730e4473751'; } File baru lib/movielist.dart import 'dart:async'; import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:flutter/material.dart'; import 'movie_detail.dart'; import 'config.dart'; class MovieList extends StatefulWidget { @override MovieListState createState() { return new MovieListState(); } } class MovieListState extends State<MovieList> { var movies; Color mainColor = const Color(0xff3C3261); void getData() async { var data = await getJson(); setState(() { movies = data['results']; }); } @override Widget build(BuildContext context) { getData(); return new Scaffold( backgroundColor: Colors.white, appBar: new AppBar( elevation: 0.3, centerTitle: true, backgroundColor: Colors.white, leading: new Icon( Icons.arrow_back, color: mainColor, ), title: new Text( 'Movies', style: new TextStyle( color: mainColor, fontFamily: 'Arvo', fontWeight: FontWeight.bold),
  • 7. ), actions: <Widget>[ new Icon( Icons.menu, color: mainColor, ) ], ), body: new Padding( padding: const EdgeInsets.all(16.0), child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ new MovieTitle(mainColor), new Expanded( child: new ListView.builder( itemCount: movies == null ? 0 : movies.length, itemBuilder: (context, i) { return new FlatButton( child: new MovieCell(movies, i), padding: const EdgeInsets.all(0.0), onPressed: () { Navigator.push(context, new MaterialPageRoute(builder: (context) { return new MovieDetail(movies[i]); })); }, color: Colors.white, ); }), ) ], ), ), ); } } Future<Map> getJson() async { var apiKey = getApiKey(); var url = 'http://api.themoviedb.org/3/discover/movie?api_key=$ {apiKey}'; var response = await http.get(url); return json.decode(response.body); } class MovieTitle extends StatelessWidget { final Color mainColor; MovieTitle(this.mainColor); @override Widget build(BuildContext context) { return new Padding( padding: const EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 16.0), child: new Text( 'Top Rated', style: new TextStyle(
  • 8. fontSize: 40.0, color: mainColor, fontWeight: FontWeight.bold, fontFamily: 'Arvo'), textAlign: TextAlign.left, ), ); } } class MovieCell extends StatelessWidget { final movies; final i; Color mainColor = const Color(0xff3C3261); var image_url = 'https://image.tmdb.org/t/p/w500/'; MovieCell(this.movies, this.i); @override Widget build(BuildContext context) { return new Column( children: <Widget>[ new Row( children: <Widget>[ new Padding( padding: const EdgeInsets.all(0.0), child: new Container( margin: const EdgeInsets.all(16.0), // child: new Image.network(image_url+movies[i]['poster_path'],width: 100.0,height: 100.0), child: new Container( width: 70.0, height: 70.0, ), decoration: new BoxDecoration( borderRadius: new BorderRadius.circular(10.0), color: Colors.grey, image: new DecorationImage( image: new NetworkImage( image_url + movies[i]['poster_path']), fit: BoxFit.cover), boxShadow: [ new BoxShadow( color: mainColor, blurRadius: 5.0, offset: new Offset(2.0, 5.0)) ], ), ), ), new Expanded( child: new Container( margin: const EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 0.0), child: new Column( children: [
  • 9. new Text( movies[i]['title'], style: new TextStyle( fontSize: 20.0, fontFamily: 'Arvo', fontWeight: FontWeight.bold, color: mainColor), ), new Padding(padding: const EdgeInsets.all(2.0)), new Text( movies[i]['overview'], maxLines: 3, style: new TextStyle( color: const Color(0xff8785A4), fontFamily: 'Arvo'), ) ], crossAxisAlignment: CrossAxisAlignment.start, ), )), ], ), new Container( width: 300.0, height: 0.5, color: const Color(0xD2D2E1ff), margin: const EdgeInsets.all(16.0), ) ], ); } } lalu yang terakhit buat file baru dengan di dalam lib/movie_detail.dart import 'package:flutter/material.dart'; import 'dart:ui' as ui; class MovieDetail extends StatelessWidget { final movie; var image_url = 'https://image.tmdb.org/t/p/w500/'; MovieDetail(this.movie); Color mainColor = const Color(0xff3C3261); @override Widget build(BuildContext context) { return new Scaffold( body: new Stack(fit: StackFit.expand, children: [ new Image.network( image_url + movie['poster_path'], fit: BoxFit.cover, ), new BackdropFilter( filter: new ui.ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0), child: new Container( color: Colors.black.withOpacity(0.5),
  • 10. ), ), new SingleChildScrollView( child: new Container( margin: const EdgeInsets.all(20.0), child: new Column( children: <Widget>[ new Container( alignment: Alignment.center, child: new Container( width: 400.0, height: 400.0, ), decoration: new BoxDecoration( borderRadius: new BorderRadius.circular(10.0), image: new DecorationImage( image: new NetworkImage( image_url + movie['poster_path']), fit: BoxFit.cover), boxShadow: [ new BoxShadow( color: Colors.black, blurRadius: 20.0, offset: new Offset(0.0, 10.0)) ]), ), new Container( margin: const EdgeInsets.symmetric( vertical: 20.0, horizontal: 0.0), child: new Row( children: <Widget>[ new Expanded( child: new Text( movie['title'], style: new TextStyle( color: Colors.white, fontSize: 30.0, fontFamily: 'Arvo'), )), new Text( '${movie['vote_average']}/10', style: new TextStyle( color: Colors.white, fontSize: 20.0, fontFamily: 'Arvo'), ) ], ), ), new Text(movie['overview'],style: new TextStyle(color: Colors.white, fontFamily: 'Arvo')), new Padding(padding: const EdgeInsets.all(10.0)), new Row(
  • 11. children: <Widget>[ new Expanded( child: new Container( width: 150.0, height: 60.0, alignment: Alignment.center, child: new Text( 'Rate Movie', style: new TextStyle( color: Colors.white, fontFamily: 'Arvo', fontSize: 20.0), ), decoration: new BoxDecoration( borderRadius: new BorderRadius.circular(10.0), color: const Color(0xaa3C3261)), )), new Padding( padding: const EdgeInsets.all(16.0), child: new Container( padding: const EdgeInsets.all(16.0), alignment: Alignment.center, child: new Icon( Icons.share, color: Colors.white, ), decoration: new BoxDecoration( borderRadius: new BorderRadius.circular(10.0), color: const Color(0xaa3C3261)), ), ), new Padding( padding: const EdgeInsets.all(8.0), child: new Container( padding: const EdgeInsets.all(16.0), alignment: Alignment.center, child: new Icon( Icons.bookmark, color: Colors.white, ), decoration: new BoxDecoration( borderRadius: new BorderRadius.circular(10.0), color: const Color(0xaa3C3261)), ) ), ], ) ], ), ), ) ]),