i'm getting null error in flutter button stopped working after added if statement inside the ontap here is my flutter code error Another exception was thrown: NoSuchMethodError: '<Unexpected Null Value>'
here is my button code
import 'package:efood_multivendor/controller/product_controller.dart';
import 'package:efood_multivendor/util/dimensions.dart';
import 'package:flutter/material.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_instance/src/extension_instance.dart';
import 'package:get/get_utils/src/extensions/internacionalization.dart';
import 'custom_snackbar.dart';
class QuantityButton extends StatelessWidget {
final bool isIncrement;
final Function onTap;
final int quantity;
final int stock;
QuantityButton(
{@required this.isIncrement,
@required this.onTap,
@required this.quantity,
@required this.stock});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap({
if(quantity < stock) {
Get.find()<ProductController>(context, listen: false).setQuantity(true);
} else {
showCustomSnackBar('out_of_stock'.tr);
}
}),
child: Container(
height: 22,
width: 22,
margin: EdgeInsets.symmetric(horizontal: Dimensions.PADDING_SIZE_SMALL),
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
width: 1,
color: isIncrement
? Theme.of(context).primaryColor
: Theme.of(context).disabledColor),
color: isIncrement
? Theme.of(context).primaryColor
: Theme.of(context).disabledColor.withOpacity(0.2),
),
),
);
}
}
please help me o solve this problem without removing onTap : onTap function