This commit is contained in:
Phaung Phaung
2021-09-10 12:02:08 +06:30
parent a144c945b6
commit c06ae00b68
35 changed files with 190 additions and 223 deletions

View File

@@ -11,7 +11,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
class DiscountByWeightEditor extends StatefulWidget {
final DiscountByWeight discountByWeight;
final DiscountByWeight? discountByWeight;
DiscountByWeightEditor({this.discountByWeight});
@override
@@ -23,14 +23,14 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
TextEditingController _discountController = new TextEditingController();
bool _isLoading = false;
bool _isNew;
bool _isNew = false;
DiscountByWeight _discountByWeight = new DiscountByWeight();
@override
void initState() {
super.initState();
if (widget.discountByWeight != null) {
_discountByWeight = widget.discountByWeight;
_discountByWeight = widget.discountByWeight!;
_weightController.text = _discountByWeight.weight.toStringAsFixed(2);
_discountController.text = _discountByWeight.discount.toString();
_isNew = false;
@@ -73,7 +73,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
},
),
backgroundColor: primaryColor,
title: Text(AppTranslations.of(context).text("discount.new")),
title: Text(AppTranslations.of(context)!.text("discount.new")),
actions: [
IconButton(
icon: Icon(Icons.delete),
@@ -117,7 +117,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
if (_isNew) {
await shipmentRateModel.addDiscountByWeight(_discount);
} else {
_discount.id = widget.discountByWeight.id;
_discount.id = this._discountByWeight.id;
await shipmentRateModel.updateDiscountByWeight(_discount);
}
Navigator.pop(context);
@@ -143,7 +143,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
var shipmentRateModel =
Provider.of<ShipmentRateModel>(context, listen: false);
await shipmentRateModel
.deleteDiscountByWeight(widget.discountByWeight.id);
.deleteDiscountByWeight(this._discountByWeight.id);
Navigator.pop(context);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
@@ -161,7 +161,7 @@ class _DiscountByWeightEditorState extends State<DiscountByWeightEditor> {
DiscountByWeight _discount = DiscountByWeight(
weight: double.parse(_weightController.text),
discount: double.parse(_discountController.text));
return widget.discountByWeight.isChangedForEdit(_discount);
return this._discountByWeight.isChangedForEdit(_discount);
}
}
}