I'm trying to validate that the second number is not zero only when user try to divide my code
CodePudding user response:
onPressed: () {
if (int.parse(secondNumberController.text) == 0) {
// show error message here
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('second num should not be zero!'),
),
);
return;
}
setState(() {
double divide = int.parse(firstNumberController.text) /
int.parse(secondNumberController.text);
result = divide.toString();
});
},