null safety

This commit is contained in:
phyothandar
2021-09-10 12:00:08 +06:30
parent a144c945b6
commit 5e672937b5
67 changed files with 901 additions and 896 deletions

View File

@@ -20,8 +20,8 @@ import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class PaymentPage extends StatefulWidget {
final Invoice invoice;
final bool forCustomer;
final Invoice? invoice;
final bool? forCustomer;
PaymentPage({this.invoice, this.forCustomer});
@override
@@ -35,15 +35,15 @@ class _PaymentPageState extends State<PaymentPage> {
Invoice _invoice = new Invoice();
bool _isLoading = false;
bool isNew;
File _file;
bool _hasBalance;
bool isNew = false;
File? _file;
bool _hasBalance = false;
@override
void initState() {
super.initState();
_invoice = widget.invoice;
_hasBalance = widget.invoice.balance > 0;
_invoice = widget.invoice!;
_hasBalance = widget.invoice!.balance > 0;
_loadInvoice();
}
@@ -129,7 +129,7 @@ class _PaymentPageState extends State<PaymentPage> {
getCustomFeeRows(BuildContext context) {
List<Widget> dataRow = [];
dataRow = _invoice?.payments?.map((p) {
dataRow = _invoice.payments.map((p) {
return Container(
decoration: BoxDecoration(
border: Border(bottom: BorderSide(color: Colors.grey))),
@@ -165,7 +165,7 @@ class _PaymentPageState extends State<PaymentPage> {
child: Column(
children: [Text('\$ ${p.amount}'), Text('${p.status}')],
))),
widget.forCustomer
widget.forCustomer!
? Container()
: Expanded(
flex: 1,
@@ -197,8 +197,7 @@ class _PaymentPageState extends State<PaymentPage> {
],
),
);
})?.toList() ??
[];
}).toList() ;
dataRow.insert(
0,
@@ -217,7 +216,7 @@ class _PaymentPageState extends State<PaymentPage> {
child: Text('Amount',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.grey))),
widget.forCustomer
widget.forCustomer!
? Container()
: Expanded(
flex: 1,
@@ -250,11 +249,11 @@ class _PaymentPageState extends State<PaymentPage> {
flex: 1,
child: Center(
child: Text(
'\$ ${widget.invoice.balance.toStringAsFixed(2)}',
'\$ ${widget.invoice!.balance.toStringAsFixed(2)}',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 16.0)))),
widget.forCustomer
widget.forCustomer!
? Container()
: Expanded(
flex: 1,
@@ -279,7 +278,7 @@ class _PaymentPageState extends State<PaymentPage> {
}
_updatePayment(Payment payment) async {
payment.invoiceID = widget.invoice.id;
payment.invoiceID = widget.invoice!.id;
setState(() {
_isLoading = true;
});
@@ -314,7 +313,7 @@ class _PaymentPageState extends State<PaymentPage> {
try {
InvoiceModel invoiceModel =
Provider.of<InvoiceModel>(context, listen: false);
await invoiceModel.pay(payment, _file);
await invoiceModel.pay(payment, _file!);
Navigator.pop(context, true);
} catch (e) {
showMsgDialog(context, "Error", e.toString());