Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6. // This widget is the root of your application.
  7. @override
  8. Widget build(BuildContext context) {
  9. return MaterialApp(
  10. title: 'Flutter Demo',
  11. theme: ThemeData(
  12. primarySwatch: Colors.blue[50],
  13. ),
  14. home: MyHomePage (title: 'Flutter Layout Demo Home Page'),
  15. );
  16. }
  17. }
  18.  
  19. class MyHomePage extends StatelessWidget {
  20. MyHomePage({Key key, this.title}): super(key: key);
  21. final String title;
  22.  
  23. @override
  24. Widget build(BuildContext context) {
  25. return Scaffold(
  26. appBar: AppBar(title: Text("Product Listing")),
  27. body: ListView(
  28. shrinkWrap: true,
  29. padding: const EdgeInsets.fromLTRB(2.0, 10.0, 2.0, 10.0),
  30. children: <Widget>[
  31. ProductBox(
  32. name: "Iphone",
  33. description: "Iphone ini serinya yang mahal loh",
  34. price: 25000000,
  35. image: "iphone.png"),
  36. ProductBox(
  37. name: "Pixl",
  38. description: "Ini bukan pixel di film-film loh",
  39. price: 1500000,
  40. image: "pixel.png"),
  41. ProductBox(
  42. name: "Macbuk",
  43. description: "Laptop untuk foto aestetik ini wajib dibeli",
  44. price: 20000000,
  45. image: "laptop.png"),
  46. ProductBox(
  47. name: "Ai-ped",
  48. description: "Ini produk keluaran Apple sama kaya iPhone dan Macbuk",
  49. price: 8000000,
  50. image: "tablet.png"),
  51. ProductBox(
  52. name: "Pendrive",
  53. description: "Ini gatau apa, tapi dijual aja deh",
  54. price: 1990000,
  55. image: "pendrive.png"),
  56. ProductBox(
  57. name: "Floppy Drive",
  58. description: "Sama seperti produk diatas, saya gatau ini apa tp harus dijual",
  59. price: 100000,
  60. image: "floppy.png"),
  61. ],
  62. ));
  63. }
  64. }
  65.  
  66. class ProductBox extends StatelessWidget {
  67. ProductBox({Key key, this.name, this.description, this.price, this.image}) : super(key: key);
  68.  
  69. final String name;
  70. final String description;
  71. final int price;
  72. final String image;
  73.  
  74. @override
  75. Widget build(BuildContext context) {
  76. return Container(
  77. padding: EdgeInsets.all(2),
  78. height: 120,
  79. child: Row(
  80. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  81. children: <Widget>[
  82. Image.asset("assets/appimages/" + image),
  83. Expanded(
  84. child: Container(
  85. padding: EdgeInsets.all(5),
  86. child: Column(
  87. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  88. children: <Widget>[
  89. Text(this.name,
  90. style: TextStyle(fontWeight: FontWeight.bold)),
  91. Text(this.description),
  92. Text("Price: " + this.price.toString()),
  93. ],
  94. ))),
  95. ],
  96. ),
  97. );
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement