Question

My Dart app has the following class hierarchy:

abstract class AbstractPresenter {
    AbstractView view;

    AbstractPresenter(this.view);

    void start(EventBus eventBus) {
        view.presenter = this;
        querySelector("body").innerHTML = view.render();
    }
}

abstract class SigninPresenter implements AbstractPresenter {
    void onSignin(MouseEvent mouseEvent);
}

class DefaultSigninPresenter implements SigninPresenter {
    // Lots of code
}

abstract class AbstractView {
    AbstractPresenter presenter;

    AbstractView(this.presenter);

    String render();

    void bindUI(String html);
}

abstract class SigninView implements AbstractView {
    SigninView(AbstractPresenter presenter) : super(presenter);

    LabelElement getSigninLabel();

    void setSigninLabel(LabelElement signinLabel);

    InputElement getEmailTextField();

    void setEmailTextField(InputElement emailTextField);
}

class DefaultSigninView implements SigninView {
    LabelElement signinLabel;
    InputElement emailTextField;

    DefaultSigninView(SigninPresenter presenter) : super(presenter);

    // Lots of code...
}

The idea is to define a hierarchy of "views" and "presenters", where ultimately a DefaultSigninView will get related (bidirectionally) to a DefaultSigninPresenter.

But I'm getting a compiler warning in DefaultSigninView's constructor, complaining about my call to super(presenter):

Missing inherited member 'AbstractView.presenter'

Why can't it "see" the presenter I'm passing it? The parent constructor (AbstractView) takes an AbstractPresenter...

Was it helpful?

Solution

This is because SigninView has not implemented all of the members of AbstractView. The same situation as your question here: Dart inheritance and super constructor

You are not extending AbstractView but implementing it. This means that you must implement a getter/setter for an AbstractPresenter presenter. Properties are not inherited if you only implement the class.

From the Dart language spec:

A class does not inherit members from its superinterfaces.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top