Dart : Abstract Method

Dart : Abstract Method

·

1 min read

Abstract Method :

  • Instance, getter, and setter methods can be abstract, defining an interface but
    leaving its implementation up to other classes.

  • To make a method abstract, use a semicolon (;) instead of a method body:

  •   abstract class Doer {
        // Define instance variables and methods...
    
        void doSomething(); // Define an abstract method.
      }
    
      class EffectiveDoer extends Doer {
        void doSomething() {
          // Provide an implementation, so the method is not abstract here...
        }
      }