flutter : concert class not called in abstract class has a static method
Static methods cannot be overridden in Dart. See this issue.
Instead do something like:
abstract class PostEditorInterface {
List<String>? f();
}
class PostEditorImpl extends PostEditorInterface {
@override
List<String>? f() { return ['hi']; }
}
// ...
final PostEditorInterface postEditor = PostEditorImpl();
final list = postEditor.f();
An example with two packages:
// package A
abstract class PostEditorInterface {
List<String>? f();
}
void methodA(PostEditorInterface postEditor) {
// no access to Impl, no problem. We have the interface.
print(postEditor.f()); // prints the list
}
// package B
import 'package A'; // let's say this works!
class PostEditorImpl extends PostEditorInterface {
@override
List<String>? f() { return ['hi']; }
}
// now use methodA as usual since here you have access to Impl
methodA(PostEditorImpl()); // it's going to print the list ['hi']