Last active
November 24, 2020 09:36
-
-
Save malinkaphann/23261ae616d79e521cc7a59766e7a280 to your computer and use it in GitHub Desktop.
how to create class with static methods in dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* author: malinkaphann@gmail.com | |
* how to create class with static and non-static methods | |
*/ | |
class MyClass { | |
static staticMethod() { | |
print('hello I am static method'); | |
} | |
void nonStaticMethod() { | |
print('hello, I am not static method'); | |
} | |
} | |
void main() { | |
// call static method directly | |
MyClass.staticMethod(); | |
// instanciate an object first | |
MyClass obj = MyClass(); | |
obj.nonStaticMethod(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment