null safety
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -20,7 +20,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PaymentPageEdit extends StatefulWidget {
|
||||
final Receipt receipt;
|
||||
final Receipt? receipt;
|
||||
PaymentPageEdit({this.receipt});
|
||||
|
||||
@override
|
||||
@@ -33,14 +33,14 @@ class _PaymentPageEditState extends State<PaymentPageEdit> {
|
||||
|
||||
Receipt _receipt = new Receipt();
|
||||
bool _isLoading = false;
|
||||
File _file;
|
||||
File? _file;
|
||||
|
||||
bool isNew;
|
||||
bool isNew = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.receipt != null) {
|
||||
_receipt = widget.receipt;
|
||||
_receipt = widget.receipt!;
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
@@ -185,11 +185,11 @@ class _PaymentPageEditState extends State<PaymentPageEdit> {
|
||||
return initialImage();
|
||||
} else {
|
||||
Widget _widget;
|
||||
if (widget.receipt.fileUrl == null) {
|
||||
if (widget.receipt!.fileUrl == null) {
|
||||
_widget = initialImage();
|
||||
} else {
|
||||
_widget = InkWell(
|
||||
child: Image.asset(widget.receipt.fileUrl, fit: BoxFit.cover),
|
||||
child: Image.asset(widget.receipt!.fileUrl, fit: BoxFit.cover),
|
||||
onTap: () {},
|
||||
);
|
||||
}
|
||||
@@ -209,13 +209,13 @@ class _PaymentPageEditState extends State<PaymentPageEdit> {
|
||||
|
||||
Widget enableUpload(BuildContext context) {
|
||||
return InkWell(
|
||||
child: Image.file(_file, fit: BoxFit.cover),
|
||||
child: Image.file(_file!, fit: BoxFit.cover),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ShowImage(imageFile: _file, url: null, fileName: 'image')));
|
||||
ShowImage(imageFile: _file!, url: '', fileName: 'image')));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user