Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't make a flutter State a Store #843

Open
SrTobi opened this issue Jul 7, 2022 · 3 comments
Open

Can't make a flutter State a Store #843

SrTobi opened this issue Jul 7, 2022 · 3 comments

Comments

@SrTobi
Copy link

SrTobi commented Jul 7, 2022

Hi

I have a problem after updating to the newest mobx version.

Take the following example:

class _MyWidgetState = _MyWidgetStateBase with _$_MyWidgetState;

abstract class _MyWidgetStateBase extends State<MyWidget> with Store {
  // ...
}

The compiler throws an error:

Superinterfaces don't have a valid override for 'context': State.context (BuildContext Function()), Store.context (ReactiveContext Function()).

Both, flutter's State and mobx's Store have a context method, but with different return types... So I cannot mixin Store into a state.

Is this intentional or unintentional? I guess I'm not supposed to make a State a store, though it worked quite well in the previous version of mobx... Can I work around this anyhow?

@fzyzcjy
Copy link
Collaborator

fzyzcjy commented Jul 7, 2022

That seems unintentional. But it does not seem to be a good practice to let a state be a store...

@amondnet
Copy link
Collaborator

amondnet commented Aug 4, 2022

@SrTobi it's a side effect. I never thought of such a case.

@SrTobi
Copy link
Author

SrTobi commented Aug 4, 2022

I guess a solution would be to add a StoreWithoutContext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants