-
Notifications
You must be signed in to change notification settings - Fork 0
/
product_manager.dart
54 lines (46 loc) · 1.26 KB
/
product_manager.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
50
51
52
53
54
import 'package:flutter/material.dart';
import './products.dart';
class ProductManager extends StatefulWidget {
final String startingProduct;
ProductManager({this.startingProduct = 'Sweets Tester'}) {
print('[ProductManager Widget] ctor');
}
@override
State<StatefulWidget> createState() {
print('[ProductManager Widget] ctor');
return _ProductManagerState();
}
}
class _ProductManagerState extends State<ProductManager> {
List<String> _products = [];
@override
void initState() {
super.initState();
_products.add(widget.startingProduct);
print('[ProductManager State] initState');
}
@override
void didUpdateWidget(ProductManager oldWidget) {
super.didUpdateWidget(oldWidget);
print('[ProductManager State] didUpdateWidget');
}
@override
Widget build(BuildContext context) {
print('[ProductManager State] build');
return Column(children: <Widget>[
Container(
margin: EdgeInsets.all(10.0),
child: RaisedButton(
color: Theme.of(context).accentColor,
child: Text('Add Product'),
onPressed: () {
setState(() {
_products.add('Advanced Food Tester');
});
},
),
),
Products(_products)
]);
}
}