-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathExample5.dart
49 lines (44 loc) · 1.69 KB
/
Example5.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import 'package:advanced_flutter_example/DefaultAppBar.dart';
import 'package:advanced_flutter_example/basic/BlocProvider.dart';
import 'package:advanced_flutter_example/basic/GlobalBloc.dart';
import 'package:advanced_flutter_example/examples/shoppingCart/Product.dart';
import 'package:advanced_flutter_example/examples/shoppingCart/ShoppingCartAppBarIcon.dart';
import 'package:flutter/material.dart';
class Example5 extends StatefulWidget {
Example5();
final String title = "Shopping Cart";
final String exampleUrl =
"https://github.com/Ephenodrom/FlutterAdvancedExamples/tree/master/lib/examples/shoppingCart";
@override
_Example5State createState() => _Example5State();
}
class _Example5State extends State<Example5> {
List<Product> productList = products;
@override
Widget build(BuildContext context) {
List<Widget> actions = [];
actions.add(ShoppingCartAppBarIcon());
return Scaffold(
appBar: DefaultAppBar(
widget.title,
widget.exampleUrl,
customActions: actions,
),
body: ListView.builder(
itemCount: productList.length,
itemBuilder: (BuildContext context, index) {
return ListTile(
title: Text(products.elementAt(index).name),
subtitle: Text(
productList.elementAt(index).priceNet.toString() + " €"),
trailing: Icon(Icons.add_shopping_cart),
onTap: () {
BlocProvider.of<GlobalBloc>(context)
.shoppingCartBloc
.addition
.add(productList.elementAt(index));
},
);
}));
}
}