Dart by Example: Static

Static members (functions or properties) are available onthe class itself, instead of on an instance of that class.

  1. class Position {
  2. // a static function
  3. static int get maxX => 100;
  4. // a static property
  5. static int maxY = 200;
  6. }
  7. main() {
  8. print(Position.maxX);
  9. print(Position.maxY);
  10. }
  11.  
  1. $ dart static.dart
  2. 100
  3. 200

by @jryanio | source | license