Untitled
unknown
dart
2 years ago
2.3 kB
31
Indexable
import 'package:flutter/material.dart'; class MyShop extends StatefulWidget { const MyShop({Key? key}) : super(key: key); @override State<MyShop> createState() => _MyShopState(); } class _MyShopState extends State<MyShop> { int jumlah_item = 0; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.orange, centerTitle: true, title: Text( 'My Shop', style: TextStyle( color: Colors.white, ), ), ), body: Center( child: Column( children: [ Image.asset( 'assets/image/item.jpg', height: 200, width: 200, ), Text( 'Kaos Polos', style: TextStyle( color: Colors.black, fontWeight: FontWeight.bold, fontSize: 20, ), ), SizedBox( height: 20, ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ ElevatedButton( onPressed: () { setState(() { jumlah_item++; }); }, child: Text('+'), ), SizedBox( width: 30, ), Text( '$jumlah_item', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 20, ), ), SizedBox( width: 30, ), ElevatedButton( onPressed: () { setState(() { jumlah_item--; }); }, child: Text('-'), ), ], ) ], ), ), floatingActionButton: ElevatedButton( onPressed: () {}, child: Icon( Icons.shopping_cart, size: 40, ), ), ); } }
Editor is loading...