颤动计算器 - 如何在用户除以零时显示错误消息

flutter calculator - how to show an error msg when user divide by zero

我正在尝试验证第二个数字是否仅在用户尝试除法时不为零 my code

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();
  });
},