Function is not a valid override of parent methods

233 Views Asked by At

How to implement D class which implements A, B & C classes.

I am understanding multiple inheritance in dart. In the below program the D class implements A, B, & C classes but its generating compile time error that 'D.foo' ('String Function()') isn't a valid override of 'A.foo' ('int Function()').

I have went through some of the previous post in SO but still unsure how to fix this issue:

Source

class $ {
  void bar() {
    print("\$ bar");
  }
}

class A extends $ {
  int foo() {
    print("A's foo");
    return 0;
  }
}

class B extends $ {
  String foo() {
    print("B's foo");
    return "Bla";
  }
}

class C extends $ {
  void foo() {
    print("C's foo");
  }
}

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

  String foo() { // Error @ this line seems its not a valid override
    return "Object()";
  }
}
0

There are 0 best solutions below