import 'package:fcs/domain/entities/fcs_shipment.dart'; import 'package:fcs/pages/fcs_shipment/model/fcs_shipment_model.dart'; import 'package:fcs/pages/widgets/local_app_bar.dart'; import 'package:fcs/pages/widgets/progress.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'invoice_customer_list.dart'; import 'invoice_shipment_list_row.dart'; class InvoiceShipmentList extends StatefulWidget { @override _InvoiceShipmentListState createState() => _InvoiceShipmentListState(); } class _InvoiceShipmentListState extends State { bool _isLoading = false; List _fcsShipments = []; @override void initState() { super.initState(); _load(); } _load() async { FcsShipmentModel fcsShipmentModel = Provider.of(context, listen: false); var fcsShipments = await fcsShipmentModel.getInvoiceFcsShipments(); setState(() { _fcsShipments = fcsShipments; }); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return LocalProgress( inAsyncCall: _isLoading, child: Scaffold( appBar: LocalAppBar(labelKey: "invoice.shipment.title"), body: new ListView.separated( separatorBuilder: (context, index) => Divider( color: Colors.black, ), scrollDirection: Axis.vertical, padding: EdgeInsets.only(top: 15), shrinkWrap: true, itemCount: _fcsShipments.length, itemBuilder: (BuildContext context, int index) { return InvoiceShipmentListRow( fcsShipment: _fcsShipments[index], onSelect: (f) { Navigator.of(context).push(CupertinoPageRoute( builder: (context) => InvoiceCustomerList(fcsShipment: f))); }, ); }), ), ); } }