Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 11.24 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:gamingshop/categories.dart';
  3. import 'package:gamingshop/product.dart';
  4. import 'package:google_fonts/google_fonts.dart';
  5.  
  6. void main() => runApp(MyApp());
  7.  
  8. class MyApp extends StatelessWidget {
  9.   // This widget is the root of your application.
  10.   @override
  11.   Widget build(BuildContext context) {
  12.     return MaterialApp(
  13.       title: 'Flutter Demo',
  14.       debugShowCheckedModeBanner: false,
  15.       theme: ThemeData(
  16.         brightness: Brightness.dark,
  17.         primarySwatch: Colors.purple,
  18.       ),
  19.       home: MyHomePage(),
  20.     );
  21.   }
  22. }
  23.  
  24. class MyHomePage extends StatelessWidget {
  25.   @override
  26.   Widget build(BuildContext context) {
  27.     return Scaffold(
  28.       appBar: AppBar(
  29.         title: Text(
  30.           "Gaming Shop",
  31.           style: GoogleFonts.nunito(
  32.             fontSize: 24,
  33.             fontWeight: FontWeight.bold,
  34.           ),
  35.         ),
  36.         elevation: 0,
  37.         actions: <Widget>[
  38.           IconButton(
  39.             icon: Icon(
  40.               Icons.shopping_cart,
  41.               // color: Colors.black,
  42.             ),
  43.             onPressed: () {},
  44.           ),
  45.         ],
  46.       ),
  47.       body: Container(
  48.         margin: EdgeInsets.only(left: 15),
  49.         child: SingleChildScrollView(
  50.           child: Column(
  51.             crossAxisAlignment: CrossAxisAlignment.start,
  52.             children: <Widget>[
  53.               SizedBox(height: 7),
  54.               Container(
  55.                 width: double.infinity,
  56.                 height: 70,
  57.                 padding: EdgeInsets.all(7),
  58.                 child: ListView.builder(
  59.                   itemCount: dummyCategories.length,
  60.                   shrinkWrap: true,
  61.                   scrollDirection: Axis.horizontal,
  62.                   itemBuilder: (BuildContext context, int index) {
  63.                     final categories = dummyCategories[index];
  64.  
  65.                     return Padding(
  66.                       padding: EdgeInsets.only(right: 15),
  67.                       child: Chip(
  68.                         shadowColor: Colors.purpleAccent,
  69.                         backgroundColor: Colors.white,
  70.                         labelPadding: EdgeInsets.fromLTRB(12, 6, 12, 6),
  71.                         elevation: 5,
  72.                         // visualDensity: VisualDensity.comfortable,
  73.                         label: Text(
  74.                           categories.name,
  75.                           style: GoogleFonts.lato(
  76.                             fontWeight: FontWeight.w700,
  77.                             textStyle: TextStyle(
  78.                               color: Colors.purpleAccent,
  79.                             ),
  80.                           ),
  81.                         ),
  82.                       ),
  83.                     );
  84.                   },
  85.                 ),
  86.               ),
  87.               SizedBox(height: 20),
  88.               Container(
  89.                 width: double.infinity,
  90.                 height: 250,
  91.                 child: ListView.builder(
  92.                   itemCount: dummyProduct.length,
  93.                   shrinkWrap: true,
  94.                   scrollDirection: Axis.horizontal,
  95.                   itemBuilder: (BuildContext context, int index) {
  96.                     final product = dummyProduct[index];
  97.                     return Container(
  98.                       width: 170,
  99.                       height: 250,
  100.                       margin: EdgeInsets.only(right: 15),
  101.                       // color: Colors.amber,
  102.                       decoration: BoxDecoration(
  103.                         borderRadius: BorderRadius.circular(16),
  104.                       ),
  105.                       child: Column(
  106.                         children: <Widget>[
  107.                           Container(
  108.                             width: 195,
  109.                             height: 170,
  110.                             decoration: BoxDecoration(
  111.                               borderRadius: BorderRadius.circular(16),
  112.                               image: DecorationImage(
  113.                                 image: AssetImage(product.urlimage),
  114.                                 fit: BoxFit.fill,
  115.                               ),
  116.                             ),
  117.                             child: Stack(
  118.                               children: <Widget>[
  119.                                 Positioned(
  120.                                   top: 0,
  121.                                   right: 0,
  122.                                   child: Container(
  123.                                     width: 35,
  124.                                     height: 35,
  125.                                     child: Icon(Icons.favorite, size: 17),
  126.                                     decoration: BoxDecoration(
  127.                                       borderRadius: BorderRadius.only(
  128.                                         bottomLeft: Radius.circular(16),
  129.                                       ),
  130.                                       color: Colors.indigo,
  131.                                     ),
  132.                                   ),
  133.                                 )
  134.                               ],
  135.                             ),
  136.                           ),
  137.                           SizedBox(
  138.                             width: 195,
  139.                             child: Text(
  140.                               product.name,
  141.                               overflow: TextOverflow.ellipsis,
  142.                               maxLines: 2,
  143.                               style: GoogleFonts.lato(
  144.                                 fontSize: 20,
  145.                                 fontWeight: FontWeight.w600,
  146.                               ),
  147.                             ),
  148.                           ),
  149.                           SizedBox(
  150.                             width: 195,
  151.                             child: Text(
  152.                               "Rp. ${product.price}",
  153.                               overflow: TextOverflow.ellipsis,
  154.                               maxLines: 2,
  155.                               style: GoogleFonts.nunito(
  156.                                 fontSize: 15,
  157.                                 fontWeight: FontWeight.w600,
  158.                                 textStyle: TextStyle(
  159.                                   color: Colors.purpleAccent,
  160.                                 ),
  161.                               ),
  162.                             ),
  163.                           ),
  164.                         ],
  165.                       ),
  166.                     );
  167.                   },
  168.                 ),
  169.               ),
  170.               SizedBox(height: 40),
  171.               Padding(
  172.                 padding: const EdgeInsets.only(right: 18.0),
  173.                 child: Row(
  174.                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
  175.                   children: <Widget>[
  176.                     Text(
  177.                       "Best Deals",
  178.                       style: GoogleFonts.nunito(
  179.                         fontSize: 24,
  180.                         fontWeight: FontWeight.bold,
  181.                       ),
  182.                     ),
  183.                     CircleAvatar(
  184.                       radius: 20,
  185.                       backgroundColor: Colors.indigo,
  186.                       child: Icon(
  187.                         Icons.arrow_forward_ios,
  188.                         size: 15,
  189.                         color: Colors.white,
  190.                       ),
  191.                     )
  192.                   ],
  193.                 ),
  194.               ),
  195.               SizedBox(height: 10),
  196.               Divider(
  197.                 height: 10,
  198.                 color: Colors.white,
  199.               ),
  200.               SizedBox(height: 10),
  201.               ListView.builder(
  202.                 itemCount: dummyProduct.length,
  203.                 shrinkWrap: true,
  204.                 physics: ScrollPhysics(),
  205.                 scrollDirection: Axis.vertical,
  206.                 itemBuilder: (BuildContext context, int index) {
  207.                   final product = dummyProduct[index];
  208.  
  209.                   return SizedBox(
  210.                     height: 100,
  211.                     child: Card(
  212.                       elevation: 7,
  213.                       margin: EdgeInsets.only(right: 10, bottom: 9),
  214.                       shape: RoundedRectangleBorder(
  215.                           borderRadius: BorderRadius.circular(16)),
  216.                       child: Row(
  217.                         children: <Widget>[
  218.                           Container(
  219.                             margin: EdgeInsets.only(left: 10),
  220.                             width: 70,
  221.                             height: 70,
  222.                             decoration: BoxDecoration(
  223.                               borderRadius: BorderRadius.circular(16),
  224.                               image: DecorationImage(
  225.                                 image: AssetImage(product.urlimage),
  226.                                 fit: BoxFit.cover,
  227.                               ),
  228.                             ),
  229.                           ),
  230.                           Container(
  231.                             padding: EdgeInsets.all(10),
  232.                             width: 230,
  233.                             child: Column(
  234.                               crossAxisAlignment: CrossAxisAlignment.start,
  235.                               children: <Widget>[
  236.                                 SizedBox(
  237.                                   child: Text(
  238.                                     product.name,
  239.                                     maxLines: 2,
  240.                                     overflow: TextOverflow.ellipsis,
  241.                                     style: GoogleFonts.lato(
  242.                                       fontSize: 18,
  243.                                       fontWeight: FontWeight.bold,
  244.                                     ),
  245.                                   ),
  246.                                 ),
  247.                                 SizedBox(
  248.                                   child: Text(
  249.                                     "Rp. ${product.price}",
  250.                                     overflow: TextOverflow.ellipsis,
  251.                                     style: GoogleFonts.lato(
  252.                                       fontSize: 15,
  253.                                       fontWeight: FontWeight.w500,
  254.                                       textStyle: TextStyle(
  255.                                         color: Colors.purpleAccent,
  256.                                       ),
  257.                                     ),
  258.                                   ),
  259.                                 ),
  260.                               ],
  261.                             ),
  262.                           ),
  263.                           Container(
  264.                             width: 25,
  265.                             height: 100,
  266.                             alignment: Alignment.center,
  267.                             decoration: BoxDecoration(
  268.                               color: Colors.purpleAccent,
  269.                               borderRadius: BorderRadius.only(
  270.                                 topRight: Radius.circular(16),
  271.                                 bottomRight: Radius.circular(16),
  272.                               ),
  273.                             ),
  274.                             child: Icon(Icons.arrow_forward_ios),
  275.                           )
  276.                         ],
  277.                       ),
  278.                     ),
  279.                   );
  280.                 },
  281.               )
  282.             ],
  283.           ),
  284.         ),
  285.       ),
  286.     );
  287.   }
  288. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement