Commit bc917573 authored by Dio Maulana's avatar Dio Maulana

oke

parent fca140a3
...@@ -6,6 +6,10 @@ import 'package:movie_app/config.dart'; ...@@ -6,6 +6,10 @@ import 'package:movie_app/config.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
class detailMovie extends StatefulWidget { class detailMovie extends StatefulWidget {
String id;
detailMovie(this.id);
@override @override
_detailMovieState createState() => _detailMovieState(); _detailMovieState createState() => _detailMovieState();
} }
...@@ -15,7 +19,7 @@ class _detailMovieState extends State<detailMovie> { ...@@ -15,7 +19,7 @@ class _detailMovieState extends State<detailMovie> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final arguments = ModalRoute.of(context)!.settings.arguments as String; final arguments = ModalRoute.of(context)!.settings.arguments as String;
var _populars = []; var _populars;
void getPopularData(String apiKey, String arguments) async { void getPopularData(String apiKey, String arguments) async {
var response = await http.get(Uri.parse( var response = await http.get(Uri.parse(
"https://api.themoviedb.org/3/movie/" + "https://api.themoviedb.org/3/movie/" +
...@@ -24,10 +28,9 @@ class _detailMovieState extends State<detailMovie> { ...@@ -24,10 +28,9 @@ class _detailMovieState extends State<detailMovie> {
apiKey + apiKey +
"&language=en-US")); "&language=en-US"));
var jsonObject = jsonDecode(response.body); var jsonObject = jsonDecode(response.body);
List<dynamic> listPopular = (jsonObject as Map<String, dynamic>)[''];
setState(() { setState(() {
_populars = listPopular; _populars = jsonObject;
}); });
} }
...@@ -105,7 +108,7 @@ class _detailMovieState extends State<detailMovie> { ...@@ -105,7 +108,7 @@ class _detailMovieState extends State<detailMovie> {
margin: EdgeInsets.only(top: 10), margin: EdgeInsets.only(top: 10),
width: 300, width: 300,
child: Text( child: Text(
arguments, _populars != null ? _populars['title'] : '',
textAlign: TextAlign.start, textAlign: TextAlign.start,
style: TextStyle( style: TextStyle(
fontSize: 25, fontSize: 25,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment