Is there an equivalent to the global keyword from python in dart/Flutter?

Viewed 91

In python we have the global keyword which allows us to use a global variable within a function much like this:

test = "this is a test"

def change_test():
    global test
    test = "I've changed it"

change_test()
print(test) # should print (I've changed it) to the console.

What is the equivalent to this in dart/flutter. I haven't find anything remotely similar.

1 Answers

It is called static variable in Flutter. Example:

void main(){
 print(Circle.pi);
}

class Circle{
 static double pi = 3.1415;
}

Here is a video explaining about static variables in Dart: https://www.youtube.com/watch?v=gmEVGdswpO0

Related