-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails on calculate #2
Comments
You may be declaring _bmi twice, check inside calculateBMI, must be like this class CalculatorBrain { final int height; double _bmi; String calculateBMI() { |
Thanks but that's not it. |
@LeeHunter you should initialize the "_bmi" value first sine the flutter update to the new version. must like this: "double _bmi = 0.0;" |
thanks a lot. |
hello, I fixed it doing like follow: I change the a bit this two methods in calculator_brain.dart String getResult(String bmi) { } String getInterpretation(String bmi) { } and I added one line in the onTap property in input_page.dart onTap: () { |
GetResult() method is being called before the calculateBMI() method, so even if you initialize _bmi to be 0.0, your app won't crash anymore but you would still get the wrong output on your screen. |
i have the same error then after i check if i change the sequence name like first bmiResult then resultText and then interpretation according to the result_page constructor in input_page navigator my error fixed try it |
This is what worked for me. Good job man. |
thanks @Hoxtygen worked like charm |
can somb tell me why I am always getting the underweight results? BMI is different but results are the same. |
I found the answer :
|
this works for me in the latest Android Studio version `class CalculatorBrain { String calculateBMI() { |
Whether I run this code my version or the "completed" version I get the following message after pressing the Calculate button:
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building Builder(dirty):
The method '>=' was called on null.
Receiver: null
Tried calling: >=(25.0)
The relevant error-causing widget was:
MaterialApp file:///Users/leehunter/angelayucourse/BMI-Calculator-Flutter-Completed/lib/main.dart:9:12
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 CalculatorBrain.getResult (package:bmi_calculator/calculator_brain.dart:17:14)
#2 _InputPageState.build.. (package:bmi_calculator/screens/input_page.dart:224:38)
#3 MaterialPageRoute.buildPage (package:flutter/src/material/page.dart:87:27)
#4 _ModalScopeState.build. (package:flutter/src/widgets/routes.dart:710:43)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
The text was updated successfully, but these errors were encountered: