phase3: nullfix field-formal field-nullable handler. 907 -> 872
This commit is contained in:
@@ -17,8 +17,8 @@ import '../../store/store.dart';
|
||||
import '../../utils/utils.dart';
|
||||
|
||||
class AddRemoveButton extends StatefulWidget {
|
||||
final Product product;
|
||||
final Business business;
|
||||
final Product? product;
|
||||
final Business? business;
|
||||
final bool addOnly;
|
||||
final int cartLineItemIndex;
|
||||
final bool addToBasket;
|
||||
@@ -59,12 +59,12 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.product.leftNum == null) {
|
||||
if (widget.product!.leftNum == null) {
|
||||
_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
|
||||
if (cartInfo.productList![i].product!.id == widget.product!.id
|
||||
&& cartInfo.productList![i].unitPrice == 0.0) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
break;
|
||||
@@ -78,7 +78,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
),
|
||||
);
|
||||
}
|
||||
if (widget.product.leftNum! <= 0) {
|
||||
if (widget.product!.leftNum! <= 0) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 0.0, bottom: 10.0, left: 8.0, right: 8.0),
|
||||
child: Text(
|
||||
@@ -105,7 +105,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
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) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
@@ -198,14 +198,14 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
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) {
|
||||
if (cartInfo.productList![i].product!.id == widget.product!.id) {
|
||||
_qty = cartInfo.productList![i].quantity!.round();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (widget.product.productAttributes != null &&
|
||||
widget.product.productAttributes!.length > 0 && widget.cartLineItemIndex == -1) {
|
||||
if (widget.product!.productAttributes != null &&
|
||||
widget.product!.productAttributes!.length > 0 && widget.cartLineItemIndex == -1) {
|
||||
return new Row(
|
||||
key: startKey,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
@@ -312,7 +312,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,
|
||||
@@ -328,7 +328,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
eventBus.fire(new OnCartInfoUpdated());
|
||||
}
|
||||
} else {
|
||||
if (widget.product.productAttributes!.length > 0) {
|
||||
if (widget.product!.productAttributes!.length > 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) =>
|
||||
@@ -337,7 +337,7 @@ class AddRemoveButtonState extends State<AddRemoveButton> {
|
||||
);
|
||||
} else {
|
||||
eventBus.fire(new OnProductWillAddToCart(widget.product, {},
|
||||
widget.product.price, widget.product.description,
|
||||
widget.product!.price, widget.product!.description,
|
||||
widget.business, buttonKey: startKey));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user