Skip to content

Instantly share code, notes, and snippets.

@malinkaphann
Last active November 24, 2020 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malinkaphann/23261ae616d79e521cc7a59766e7a280 to your computer and use it in GitHub Desktop.
Save malinkaphann/23261ae616d79e521cc7a59766e7a280 to your computer and use it in GitHub Desktop.
how to create class with static methods in dart
/**
* 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