How to create Method in DART

In this article, I am going to explain Dart method.
  • 2739

Methods in Dart

An orderly process is called method. Dart have two method-

  • Instance method

    Instance methods on objects can access instance variable

Example of instance method

class InstanceMet{


    print("I am a Instance Method");



void main() {

  InstanceMet obj = new InstanceMet();




  • Static method

    Static method resolved at compile time. In static method you can  only use  static data member, and there is a no need to create a object; you can call static method by it's class name.

Example of static method

class StaticMeth{

  static int i=5;

  static int  Method(){

    print("Static method value is ${i}");



void main() {

  StaticMeth.Method(); // calling of static method


 static method.png

Ask Your Question 

Got a programming related question? You may want to post your question here
© 2020 DotNetHeaven. All rights reserved.