Advertisement
sigitsuryono25

main.dart full code

Dec 12th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 13.74 KB | None | 0 0
  1. import 'package:carousel_pro/carousel_pro.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter/services.dart';
  5. import 'package:flutter_svg/flutter_svg.dart';
  6. import 'package:wisata_yogyakarta/GalleryWisata.dart';
  7. import 'package:wisata_yogyakarta/LokasiWisata.dart';
  8. import 'package:wisata_yogyakarta/PortalBerita.dart';
  9. import 'package:wisata_yogyakarta/VideoWisata.dart';
  10.  
  11. void main() => runApp(MyApp());
  12.  
  13. class MyApp extends StatelessWidget {
  14.   // This widget is the root of your application.
  15.   @override
  16.   Widget build(BuildContext context) {
  17.     return MaterialApp(
  18.       title: 'Flutter Demo',
  19.       theme: ThemeData(
  20.         // This is the theme of your application.
  21.         //
  22.         // Try running your application with "flutter run". You'll see the
  23.         // application has a blue toolbar. Then, without quitting the app, try
  24.         // changing the primarySwatch below to Colors.green and then invoke
  25.         // "hot reload" (press "r" in the console where you ran "flutter run",
  26.         // or simply save your changes to "hot reload" in a Flutter IDE).
  27.         // Notice that the counter didn't reset back to zero; the application
  28.         // is not restarted.
  29.         primarySwatch: Colors.green,
  30.       ),
  31.       home: MyHomePage(title: 'Dashboard'),
  32.     );
  33.   }
  34. }
  35.  
  36. class MyHomePage extends StatefulWidget {
  37.   MyHomePage({Key key, this.title}) : super(key: key);
  38.  
  39.   // This widget is the home page of your application. It is stateful, meaning
  40.   // that it has a State object (defined below) that contains fields that affect
  41.   // how it looks.
  42.  
  43.   // This class is the configuration for the state. It holds the values (in this
  44.   // case the title) provided by the parent (in this case the App widget) and
  45.   // used by the build method of the State. Fields in a Widget subclass are
  46.   // always marked "final".
  47.  
  48.   final String title;
  49.  
  50.   @override
  51.   _MyHomePageState createState() => _MyHomePageState();
  52. }
  53.  
  54. class _MyHomePageState extends State<MyHomePage> {
  55.   // Image list
  56.   static final List imgList = [
  57.     NetworkImage(
  58.         "https://www.pikniek.com/wp-content/uploads/2017/10/000015-00_wisata-candi-prambanan_kompleks-candi_800x450_cc0-min.jpg"),
  59.     NetworkImage(
  60.         "http://spotunik.com/assets/images/spots/tugu-jogja-20160620160402.jpg"),
  61.     NetworkImage(
  62.         "http://cdn-2.tstatic.net/tribunnews/foto/bank/images/pemandangan-candi-ijo2_20150519_174558.jpg"),
  63.     NetworkImage(
  64.         "https://www.yogyes.com/en/yogyakarta-tourism-object/candi/ijo/1.jpg")
  65.   ];
  66.  
  67.   @override
  68.   Widget build(BuildContext context) {
  69.     final MediaQueryData _mediaQueryData = MediaQuery.of(context);
  70.     return Scaffold(
  71.       appBar: AppBar(
  72.         title: Text(widget.title),
  73.       ),
  74.       body: Center(
  75.         child: Column(
  76.           children: <Widget>[
  77.             SizedBox(
  78.               width: _mediaQueryData.size.width,
  79.               height: 250,
  80.               child: Carousel(
  81.                 images: imgList,
  82.                 dotBgColor: Colors.transparent,
  83.                 dotPosition: DotPosition.bottomLeft,
  84.                 boxFit: BoxFit.cover,
  85.                 showIndicator: true,
  86.                 dotSize: 5,
  87.                 autoplay: true,
  88.                 autoplayDuration: Duration(milliseconds: 3000),
  89.                 onImageTap: (index) {
  90.                   print(imgList[index]);
  91.                 },
  92.               ),
  93.             ),
  94.             Container(
  95.               padding: EdgeInsetsDirectional.only(top: 20),
  96.               child: Column(
  97.                 children: <Widget>[
  98.                   Row(
  99.                     children: <Widget>[
  100.                       Expanded(
  101.                         child: GestureDetector(
  102.                           child: Column(
  103.                             children: <Widget>[
  104.                               SvgPicture.asset(
  105.                                 "graphics/home.svg",
  106.                                 width: 64,
  107.                                 height: 64,
  108.                               ),
  109.                               SizedBox(
  110.                                 height: 10,
  111.                               ),
  112.                               Text(
  113.                                 "Dashboard",
  114.                                 style: TextStyle(
  115.                                     color: Colors.black,
  116.                                     fontWeight: FontWeight.bold),
  117.                               )
  118.                             ],
  119.                           ),
  120.                           onTap: () {
  121.                             print("Dashboard");
  122.                           },
  123.                         ),
  124.                       ),
  125.                       Expanded(
  126.                         child: GestureDetector(
  127.                           child: Column(
  128.                             children: <Widget>[
  129.                               SvgPicture.asset(
  130.                                 "graphics/rss.svg",
  131.                                 height: 64,
  132.                                 width: 64,
  133.                               ),
  134.                               SizedBox(
  135.                                 height: 10,
  136.                               ),
  137.                               Text(
  138.                                 "Portal Wisata",
  139.                                 style: TextStyle(
  140.                                     color: Colors.black,
  141.                                     fontWeight: FontWeight.bold),
  142.                               )
  143.                             ],
  144.                           ),
  145.                           onTap: () {
  146.                             Navigator.push(
  147.                                 context,
  148.                                 MaterialPageRoute(
  149.                                     builder: (context) => PortalBerita()));
  150.                           },
  151.                         ),
  152.                       ),
  153.                     ],
  154.                   ),
  155.                   SizedBox(
  156.                     height: 20,
  157.                   ),
  158.                   Row(
  159.                     children: <Widget>[
  160.                       Expanded(
  161.                         child: GestureDetector(
  162.                           child: Column(
  163.                             children: <Widget>[
  164.                               SvgPicture.asset(
  165.                                 "graphics/map.svg",
  166.                                 height: 64,
  167.                                 width: 64,
  168.                               ),
  169.                               SizedBox(
  170.                                 height: 10,
  171.                               ),
  172.                               Text(
  173.                                 "Lokasi Wisata",
  174.                                 style: TextStyle(
  175.                                     fontWeight: FontWeight.bold,
  176.                                     color: Colors.black),
  177.                               )
  178.                             ],
  179.                           ),
  180.                           onTap: () {
  181.                             Navigator.push(
  182.                                 context,
  183.                                 MaterialPageRoute(
  184.                                     builder: (context) => LokasiWisata()));
  185.                           },
  186.                         ),
  187.                       ),
  188.                       Expanded(
  189.                         child: GestureDetector(
  190.                           child: Column(
  191.                             children: <Widget>[
  192.                               SvgPicture.asset(
  193.                                 "graphics/video-player.svg",
  194.                                 height: 64,
  195.                                 width: 64,
  196.                               ),
  197.                               SizedBox(
  198.                                 height: 10,
  199.                               ),
  200.                               Text(
  201.                                 "Video Wisata",
  202.                                 style: TextStyle(
  203.                                     fontWeight: FontWeight.bold,
  204.                                     color: Colors.black),
  205.                               )
  206.                             ],
  207.                           ),
  208.                           onTap: () {
  209.                             Navigator.push(
  210.                                 context,
  211.                                 MaterialPageRoute(
  212.                                     builder: (context) => VideoWisata()));
  213.                           },
  214.                         ),
  215.                       )
  216.                     ],
  217.                   ),
  218.                   SizedBox(
  219.                     height: 20,
  220.                   ),
  221.                   Row(
  222.                     children: <Widget>[
  223.                       Expanded(
  224.                         child: GestureDetector(
  225.                           child: Column(
  226.                             children: <Widget>[
  227.                               SvgPicture.asset(
  228.                                 "graphics/gallery.svg",
  229.                                 height: 64,
  230.                                 width: 64,
  231.                               ),
  232.                               SizedBox(
  233.                                 height: 10,
  234.                               ),
  235.                               Text(
  236.                                 "Galeri Wisata",
  237.                                 style: TextStyle(
  238.                                     fontWeight: FontWeight.bold,
  239.                                     color: Colors.black),
  240.                               )
  241.                             ],
  242.                           ),
  243.                           onTap: () {
  244.                             Navigator.push(
  245.                                 context,
  246.                                 MaterialPageRoute(
  247.                                     builder: (context) => GalleryWisata()));
  248.                           },
  249.                         ),
  250.                       ),
  251.                       Expanded(
  252.                         child: GestureDetector(
  253.                           child: Column(
  254.                             children: <Widget>[
  255.                               SvgPicture.asset(
  256.                                 "graphics/complain.svg",
  257.                                 height: 64,
  258.                                 width: 64,
  259.                               ),
  260.                               SizedBox(
  261.                                 height: 10,
  262.                               ),
  263.                               Text(
  264.                                 "About Us",
  265.                                 style: TextStyle(
  266.                                     fontWeight: FontWeight.bold,
  267.                                     color: Colors.black),
  268.                               ),
  269.                             ],
  270.                           ),
  271.                           onTap: () {},
  272.                         ),
  273.                       )
  274.                     ],
  275.                   )
  276.                 ],
  277.               ),
  278.             )
  279.           ],
  280.         ),
  281.       ),
  282.       drawer: Drawer(
  283.         child: ListView(
  284.           children: <Widget>[
  285.             UserAccountsDrawerHeader(
  286.                 decoration: BoxDecoration(
  287.                   image: DecorationImage(
  288.                       image: AssetImage("graphics/bg.jpg"), fit: BoxFit.fill),
  289.                 ),
  290.                 currentAccountPicture: CircleAvatar(
  291.                   child: Text("A"),
  292.                   backgroundColor: Colors.white,
  293.                 ),
  294.                 accountName: Text("Admin"),
  295.                 accountEmail: Text("admin@example.com")),
  296.             Container(
  297.               padding: EdgeInsetsDirectional.only(start: 20.0, top: 10.0),
  298.               child: Text("Menu Utama"),
  299.             ),
  300.             ListTile(
  301.               leading: Icon(Icons.dashboard),
  302.               title: Text("Dashboard"),
  303.               onTap: null,
  304.             ),
  305.             ListTile(
  306.               leading: Icon(Icons.web),
  307.               title: Text("Portal Berita"),
  308.               onTap: () {
  309.                 Navigator.of(context).pop();
  310.                 Navigator.push(context,
  311.                     MaterialPageRoute(builder: (context) => PortalBerita()));
  312.               },
  313.             ),
  314.             ListTile(
  315.               leading: Icon(Icons.map),
  316.               title: Text("Lokasi Wisata"),
  317.               onTap: () {
  318.                 Navigator.of(context).pop();
  319.                 Navigator.push(context,
  320.                     MaterialPageRoute(builder: (context) => LokasiWisata()));
  321.               },
  322.             ),
  323.             ListTile(
  324.               leading: Icon(Icons.videocam),
  325.               title: Text("Video Wisata"),
  326.               onTap: () {
  327.                 Navigator.of(context).pop();
  328.                 Navigator.push(context,
  329.                     MaterialPageRoute(builder: (context) => VideoWisata()));
  330.               },
  331.             ),
  332.             ListTile(
  333.               leading: Icon(Icons.photo_library),
  334.               title: Text("Galeri Wisata"),
  335.               onTap: () {
  336.                 Navigator.of(context).pop();
  337.                 Navigator.push(context,
  338.                     MaterialPageRoute(builder: (context) => GalleryWisata()));
  339.               },
  340.             ),
  341.             Divider(
  342.               color: Colors.grey,
  343.               height: 1,
  344.             ),
  345.             Container(
  346.               padding: EdgeInsetsDirectional.only(start: 20.0, top: 10.0),
  347.               child: Text("Lain-Lain"),
  348.             ),
  349.             ListTile(
  350.               leading: Icon(Icons.person),
  351.               title: Text("Tentang Pengembang"),
  352.               onTap: null,
  353.             ),
  354.             ListTile(
  355.               leading: Icon(Icons.power_settings_new),
  356.               title: Text("Keluar"),
  357.               onTap: () {
  358.                 SystemNavigator.pop();
  359.               },
  360.             ),
  361.           ],
  362.         ),
  363.       ),
  364.     );
  365.   }
  366. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement