import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:fcs/model/chart_model.dart'; import 'package:fcs/model/language_model.dart'; import 'package:fcs/fcs/common/theme.dart'; import 'package:fcs/vo/po.dart'; import 'package:fcs/widget/local_text.dart'; import 'package:fcs/widget/localization/app_translations.dart'; import 'package:fcs/widget/my_data_table.dart'; import 'package:fcs/widget/number_cell.dart'; import 'package:fcs/widget/progress.dart'; class POBalanceTable extends StatefulWidget { final POChartData poChartData; const POBalanceTable({Key key, this.poChartData}) : super(key: key); @override _POBalanceTableState createState() => _POBalanceTableState(); } class _POBalanceTableState extends State { final numberFormatter = new NumberFormat("#,###"); List chartUser = new List(); bool _isLoading = false; @override void initState() { super.initState(); var chartModel = Provider.of(context, listen: false); if (mounted) { load(chartModel); } } Future load(ChartModel chartModel) async { var _u = await chartModel.loadPOBalProductsForBuyer(); setState(() { this.chartUser = _u; }); } @override Widget build(BuildContext context) { List data = this .chartUser .where((u) => u.productName == widget.poChartData.productName) .toList(); return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: AppBar( backgroundColor: primaryColor, title: Text( AppTranslations.of(context).text("product.qtys"), style: Provider.of(context).isEng ? TextStyle(fontSize: 18) : TextStyle(fontSize: 18, fontFamily: 'MyanmarUnicode'), ), ), body: Container( padding: EdgeInsets.only(top: 10), child: SingleChildScrollView( scrollDirection: Axis.vertical, child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: MyDataTable( headingRowHeight: 40, columnSpacing: 40, columns: [ MyDataColumn(label: LocalText(context, "buyer.name")), MyDataColumn(label: LocalText(context, "buyer.product")), MyDataColumn( label: LocalText(context, "buyer.balQty"), numeric: true), ], rows: getProductRow(data), ), ), ), ), ), ); } List getProductRow(List poLines) { return poLines.map((p) { return MyDataRow( cells: [ MyDataCell( new Text(p.userName, style: textStyle), ), MyDataCell( new Text( p.productName, style: textStyle, ), ), MyDataCell( NumberCell(p.balanceQty), //new Text(numberFormatter.format(p.balanceQty), style: textStyle), ), ], ); }).toList(); } }