fix(runtime): 37 late fields with == null checks were wrongly migrated -> nullable. Fixes LateInitializationError crashes on page navigation (shop/checkout/comment/data pages)
This commit is contained in:
@@ -48,7 +48,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
var d = 1;
|
||||
|
||||
late CartInfo cartInfo;
|
||||
CartInfo? cartInfo;
|
||||
|
||||
GlobalKey startKey = GlobalKey();
|
||||
|
||||
@@ -63,10 +63,10 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!)!;
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product!.id
|
||||
&& cartInfo.productList![i].unitPrice == 0.0) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
for (var i = 0; i < cartInfo!.productList!.length; i++) {
|
||||
if (cartInfo!.productList![i].product!.id == widget.product!.id
|
||||
&& cartInfo!.productList![i].unitPrice == 0.0) {
|
||||
_qty = cartInfo!.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -104,9 +104,9 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!)!;
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
for (var i = 0; i < cartInfo!.productList!.length; i++) {
|
||||
if (cartInfo!.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo!.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -196,9 +196,9 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
_qty = 0;
|
||||
cartInfo = Utils.getCartInfoByBusiness(store.state.cartInfos, widget.business!)!;
|
||||
if (cartInfo != null) {
|
||||
for (var i = 0; i < cartInfo.productList!.length; i++) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
for (var i = 0; i < cartInfo!.productList!.length; i++) {
|
||||
if (cartInfo!.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo!.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
void _addToCart(BuildContext context) {
|
||||
if (widget.cartLineItemIndex != -1) {
|
||||
if (cartInfo.productList![widget.cartLineItemIndex].quantity! + 1.0 > widget.product!.leftNum!) {
|
||||
if (cartInfo!.productList![widget.cartLineItemIndex].quantity! + 1.0 > widget.product!.leftNum!) {
|
||||
Fluttertoast.showToast(
|
||||
msg: S.of(context).product_insufficient,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
@@ -320,10 +320,10 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
textColor: Colors.white
|
||||
);
|
||||
} else {
|
||||
cartInfo.productList![widget.cartLineItemIndex].quantity = (cartInfo.productList![widget.cartLineItemIndex].quantity ?? 0) + 1.0;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex]);
|
||||
cartInfo!.productList![widget.cartLineItemIndex].quantity = (cartInfo!.productList![widget.cartLineItemIndex].quantity ?? 0) + 1.0;
|
||||
Utils.addSubproductQty(cartInfo!, cartInfo!.productList![widget.cartLineItemIndex]);
|
||||
store.dispatch(UpdateCartInfo(
|
||||
Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo!)));
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
}
|
||||
} else {
|
||||
@@ -344,7 +344,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
void _removeFromCart(BuildContext context) {
|
||||
if (widget.cartLineItemIndex != -1) {
|
||||
if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
if (cartInfo!.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@@ -379,18 +379,18 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
}
|
||||
|
||||
void _removeCartLineItem() {
|
||||
if (cartInfo.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
String uuid = cartInfo.productList![widget.cartLineItemIndex].uuid!;
|
||||
cartInfo.productList!.removeAt(widget.cartLineItemIndex);
|
||||
Utils.removeSubproduct(cartInfo, uuid);
|
||||
if (cartInfo!.productList![widget.cartLineItemIndex].quantity! <= 1) {
|
||||
String uuid = cartInfo!.productList![widget.cartLineItemIndex].uuid!;
|
||||
cartInfo!.productList!.removeAt(widget.cartLineItemIndex);
|
||||
Utils.removeSubproduct(cartInfo!, uuid);
|
||||
} else {
|
||||
cartInfo.productList![widget.cartLineItemIndex].quantity = (cartInfo.productList![widget.cartLineItemIndex].quantity ?? 0) - 1;
|
||||
Utils.addSubproductQty(cartInfo, cartInfo.productList![widget.cartLineItemIndex], remove: true);
|
||||
cartInfo!.productList![widget.cartLineItemIndex].quantity = (cartInfo!.productList![widget.cartLineItemIndex].quantity ?? 0) - 1;
|
||||
Utils.addSubproductQty(cartInfo!, cartInfo!.productList![widget.cartLineItemIndex], remove: true);
|
||||
}
|
||||
if (cartInfo.productList!.length <= 0) {
|
||||
if (cartInfo!.productList!.length <= 0) {
|
||||
store.dispatch(new UpdateCartInfo(Utils.removeCartInfoFromCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
} else {
|
||||
store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo)));
|
||||
store.dispatch(new UpdateCartInfo(Utils.addCartInfoToCartInfoList(store.state.cartInfos, cartInfo!)));
|
||||
}
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user