simple widget tree with managing data with each

This commit is contained in:
talksik
2019-05-26 00:52:01 -07:00
parent c6de0ce9b2
commit 0d9ee1c1b6
3 changed files with 67 additions and 32 deletions
+4 -32
View File
@@ -1,18 +1,10 @@
import 'package:flutter/material.dart';
import './product_manager.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _MyAppState();
}
}
class _MyAppState extends State<MyApp> {
List<String> _products = ['Test'];
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@@ -22,27 +14,7 @@ class _MyAppState extends State<MyApp> {
),
body: Column(
children: [
Container(
margin: EdgeInsets.all(10),
child: RaisedButton(
onPressed: () {
setState(() {
_products.add('Advanced Food Tester');
});
},
child: Text('Click Me!'),
)),
Column(
children: _products
.map((elem) => Card(
child: Column(
children: <Widget>[
Image.asset('assets/food.jpg'),
Text(elem)
],
)))
.toList(),
),
ProductManager('Test'),
],
),
));