Commit 0b4af86c authored by Dio Maulana's avatar Dio Maulana

detail done

parent bc917573
......@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import 'package:movie_app/pages/main_page.dart';
import 'package:movie_app/pages/movie_detail.dart';
import 'models/movie_detail_arg.dart';
void main() {
runApp(MyApp());
}
......@@ -15,10 +17,24 @@ class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
// onGenerateRoute: (settings) {
// if (settings.name == '/detail') {
// final args = settings.arguments.toString();
// return PageRouteBuilder(
// settings: settings,
// pageBuilder: (_, __, ___) => detailMovie(args),
// transitionsBuilder: (_, a, __, c) => FadeTransition(
// opacity: a,
// child: c,
// ));
// }
// },
initialRoute: '/',
routes: {
'/': (context) => MainPages(),
'/detail': (context) => detailMovie(),
'/detail': (context) => detailMovie(
// ModalRoute.of(context)!.settings.arguments as ScreenArguments),
ModalRoute.of(context)!.settings.arguments as String),
},
);
}
......
class movieDetail {
final String title;
final String poster_path;
final String overview;
final double vote_average;
List<dynamic> genre = [];
movieDetail(this.title, this.poster_path, this.overview, this.vote_average,
this.genre);
factory movieDetail.fromJson(dynamic json) {
var nameGenre = [];
for (int i = 0; i < json['genres'].length; i++) {
print(json['genres'][i]['name']);
var genreName = '';
if (json['genres'][i]['name'] == null) {
genreName = 'Thriller';
} else {
genreName = json['genres'][i]['name'];
}
nameGenre.add(genreName);
}
return movieDetail(
json['title'] as String,
json['poster_path'] as String,
json['overview'] as String,
json['vote_average'] as double,
nameGenre as List<dynamic>);
}
}
class ScreenArguments {
final String id;
final String image;
ScreenArguments(this.id, this.image);
}
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatelessWidget(),
),
);
}
}
class MyStatelessWidget extends StatelessWidget {
const MyStatelessWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(
child: ElevatedButton(
child: const Text('showModalBottomSheet'),
onPressed: () {
showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(
height: 200,
color: Colors.amber,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Modal BottomSheet'),
ElevatedButton(
child: const Text('Close BottomSheet'),
onPressed: () => Navigator.pop(context),
)
],
),
),
);
},
);
},
),
);
}
}
......@@ -6,6 +6,7 @@ import 'package:http/http.dart' as http;
import 'package:movie_app/pages/movie_detail.dart';
import '../config.dart';
// import '../models/movie_detail_arg.dart';
class MainPages extends StatefulWidget {
@override
......@@ -219,6 +220,10 @@ class _MainPagesState extends State<MainPages> {
Navigator.pushNamed(
context,
'/detail',
// arguments: ScreenArguments(
// id,
// image,
// ),
arguments: id,
);
},
......
This diff is collapsed.
......@@ -69,6 +69,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_rating_bar:
dependency: "direct main"
description:
name: flutter_rating_bar
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
......@@ -186,3 +193,4 @@ packages:
version: "2.1.1"
sdks:
dart: ">=2.16.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
......@@ -30,15 +30,10 @@ dependencies:
cupertino_icons: ^1.0.2
flutter:
sdk: flutter
flutter_rating_bar: ^4.0.0
http: ^0.13.4
dev_dependencies:
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^1.0.0
flutter_test:
sdk: flutter
......
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