Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() => runApp(MyApp());
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue[50],
- ),
- home: MyHomePage (title: 'Flutter Layout Demo Home Page'),
- );
- }
- }
- class MyHomePage extends StatelessWidget {
- MyHomePage({Key key, this.title}): super(key: key);
- final String title;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(title: Text("Product Listing")),
- body: ListView(
- shrinkWrap: true,
- padding: const EdgeInsets.fromLTRB(2.0, 10.0, 2.0, 10.0),
- children: <Widget>[
- ProductBox(
- name: "Iphone",
- description: "Iphone ini serinya yang mahal loh",
- price: 25000000,
- image: "iphone.png"),
- ProductBox(
- name: "Pixl",
- description: "Ini bukan pixel di film-film loh",
- price: 1500000,
- image: "pixel.png"),
- ProductBox(
- name: "Macbuk",
- description: "Laptop untuk foto aestetik ini wajib dibeli",
- price: 20000000,
- image: "laptop.png"),
- ProductBox(
- name: "Ai-ped",
- description: "Ini produk keluaran Apple sama kaya iPhone dan Macbuk",
- price: 8000000,
- image: "tablet.png"),
- ProductBox(
- name: "Pendrive",
- description: "Ini gatau apa, tapi dijual aja deh",
- price: 1990000,
- image: "pendrive.png"),
- ProductBox(
- name: "Floppy Drive",
- description: "Sama seperti produk diatas, saya gatau ini apa tp harus dijual",
- price: 100000,
- image: "floppy.png"),
- ],
- ));
- }
- }
- class ProductBox extends StatelessWidget {
- ProductBox({Key key, this.name, this.description, this.price, this.image}) : super(key: key);
- final String name;
- final String description;
- final int price;
- final String image;
- @override
- Widget build(BuildContext context) {
- return Container(
- padding: EdgeInsets.all(2),
- height: 120,
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: <Widget>[
- Image.asset("assets/appimages/" + image),
- Expanded(
- child: Container(
- padding: EdgeInsets.all(5),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: <Widget>[
- Text(this.name,
- style: TextStyle(fontWeight: FontWeight.bold)),
- Text(this.description),
- Text("Price: " + this.price.toString()),
- ],
- ))),
- ],
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement