Interface

Syntax & Properties of interface

void main() {
  // Interfaces in dart
}

abstract class A {
  String a;

  void testA1();

  void testA2() {
    print("A2");
  }
}

abstract class B {
  void testB1();

  void testB2() {
    print("B2");
  }
}

class C implements A, B {
  @override
  void testB1() {}

  @override
  void testB2() {}

  @override
  String a;

  @override
  void testA1() {}

  @override
  void testA2() {}
}

Interface : Why we use them -1 ?

Interface : Why we use them -2 ?

Though dart gives us the flexibility to implement any class , most of the time you are going to implement abstract classes containing abstract methods (i.e. turning those abstract classes into interfaces )

Last updated

Was this helpful?