Dart Static Method
In this tutorial, we will understand the concept of the Dart static method. Static methods are members of the class instead of the class instance. They can use only static variables and invoke the class’s static methods. We don’t need to create an instance of the class to access them. The static method is useful when used in other classes.
Syntax
We can declare the static method by using the static keyword followed by the method name and the method return type.
The general syntax to declare a static method is as follows:
static return_type method_name() {
// static method statement(s)
}
Calling Static Method
We can access static methods using the class name. We can invoke the static method using the class name with a dot operator and the static method name.
The general syntax to access the static method is as follows:
ClassName.staticMethod();
Static methods are also known as class methods. The static methods are the members of the class instead of its object. A single copy of the static method is shared among all the instances of a class.
—
Dart Tutorials
Dart tutorial on this website can be found at:
https://www.testingdocs.com/dart-tutorials-for-beginners/
More information on Dart: