Search code examples
dartabstract-class

IntelliJ reporting that abstract class is missing implementation of concrete method, but method is implemented in abstract class?


I have an abstract Dart class which contains some abstract methods and a concrete, implemented method that I want to keep consistent across all subclasses.

IntelliJ's Dart Analysis system is reporting in subclasses that no concrete implementation exists for my implemented method — even though I can see that abstract has a concrete implementation.

I have also tried implementing the method in my subclass and calling the super class, but that is also reported as not being implemented. Both abstract class and child class are in the same file.

abstract class Exporter {
  List<String> getHeaderRow();
  List<dynamic> getEntryAsRow(EntriesData entry);

  /// Concrete implementation
  dynamic getVal(dynamic value) {
    return null;
  }
}

// ExpenseReport underlined in red: missing concrete implementation of getVal
class ExpenseReport implements Exporter {
  List<String> getHeaderRow() {
    return [];
  }

  List<dynamic> getEntryAsRow(EntriesData entry) {
    return [];
  }

//  dynamic getVal(dynamic value) {
//    super.getVal(value); // IntelliJ reports "getval" as abstract in superclass
//  }

}

Solution

  • Saying

    class ExpenseReport implements Exporter
    

    you mean your ExpenseReport implements interface of Exporter, which in turn means that it has to implement all methods declared in Exporter.

    If you want to inherit implemented methods from abstract Exporter you need to extend it like this:

    class ExpenseReport extends Exporter