import 'package:flutter/material.dart';
void main() {
runApp(HomePage());
}
class HomePage extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
home: MyApp(),
);
}
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState()=> _MyAppState();
}
class _MyAppState extends State<MyApp>{
List<Map> names = [{'NO':1,'rowcode':'rowcode1'}];
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(
title: Text('ssss'),
),
body: Column(
children: [
Container(
child: MaterialButton(
child: Text('ssss'),
onPressed: ()async{
await showDialog(
context: context,
builder: (BuildContext context){
return StatefulBuilder(
builder:(context, setState) {
return SimpleDialog(
title: Text('ssssssss'),
children: [
Container(
child: Text('sssddddddddddd'),
),
Row(
children: [
MaterialButton(child: Text('confirm'),
onPressed: () {
names[0]['qty'] = 123;
names.add({
'NO': 2,
'rowcode': 'rowcode2',
'qty': 33
});
Navigator.pop(context);
// setState((){});
},
),
],
),
],
);
}
);
}
).then((value) => setState((){}));
},
),
),
Container(
child: ListView.builder(
itemCount: names.length,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index){
return ListTile(
leading: Icon(Icons.widgets),
title: Text('${names[index]['NO']}'),
subtitle: Text('${names[index]['rowcode']}'),
trailing: Text('${names[index]['qty']}'),
);
},
),
),
],
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: (){
setState(() {
print(names);
});
},
),
);
}
}