Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Guidance please #20

Closed
kentcb opened this issue Jan 31, 2018 · 2 comments
Closed

Guidance please #20

kentcb opened this issue Jan 31, 2018 · 2 comments

Comments

@kentcb
Copy link

kentcb commented Jan 31, 2018

Hi,

I've been spiking out flutter flux and could use some guidance. I have a repo here. Note that my dependency on flutter_flux is a source dependency, due to the binaries on pub being old.

My use case is a login dialog. I already have it working in plain old flutter, but I want to separate the logic out, hence my spiking with flutter_flux. I've left a few TODO comments in the code, but in short I'm a bit stuck on how to do things The Right Way™.

And there's one debilitating bug in my code that I've not found a workaround for yet. I need to pop the modal when authentication succeeds, but I'm doing so from my build method, which of course triggers a setState() or markNeedsBuild() called during build assertion violation. I'm just not sure where else I could do this.

Can someone please offer some guidance?

Thanks

@kentcb
Copy link
Author

kentcb commented Jan 31, 2018

Update: regarding the debilitating bug, I ended up using a future from my widget to dismiss the modal:

    if (_store.isAuthenticated) {
      new Future(() {
        Navigator.of(context).pop(_store.user);
      });
      return new Text("");
    }

This works, but still feels a bit weird, considering I'm just returning an empty Text to avoid returning null.

@jimbeveridge
Copy link
Contributor

Sorry if this is a little late. This doesn't really look like a flux question - the Navigator.of.pop() call isn't related to flux. Your solution works because it moves the call outside of the build method, but it seems like a better solution would be to listen for changes to isAuthenticated in the store (outside of your build method) and then make the call to Navigator when you are notified of that change.

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

No branches or pull requests

2 participants