Issue
I declared one variable in dart as follows-
var Latitude;
void GetCLocation() async {
Latitude=1;
}
main(){
print(Latitude);
}
The problem is that the output is not coming out to be 1, but it is coming out to be null. What am I doing wrong?
Solution
Do this instead, you should call the function for it to be assign:
void main() {
var Latitude;
void GetCLocation() async {
Latitude=1;
}
GetCLocation();
print(Latitude);
}
Answered By – Wilson Toribio
Answer Checked By – David Goodson (FlutterFixes Volunteer)