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

How to do routing? #2

Closed
puruzio opened this issue Sep 10, 2018 · 2 comments
Closed

How to do routing? #2

puruzio opened this issue Sep 10, 2018 · 2 comments

Comments

@puruzio
Copy link

puruzio commented Sep 10, 2018

Not an issue but a question.

What do you recommend for routing for SPA's using Dartea?
Something like Elm's Navigation module for Dart?

@p69
Copy link
Owner

p69 commented Sep 10, 2018

Hi @puruzio ,

Well, there are two ways how to make navigation in Flutter with Dartea.

  1. Traditional Elm approach. We have root model, which contains current page. Each page have its update, view, messages. When the message comes to root model it recognizes message somehow (by type or enum) and forward it to right update function. You can find example of such navigation model here. It's link to root model (home) which contains two tabs todos and stats. It works well for this case because it uses BottomNavigationBar for switching between tabs.

  2. But it doesn't work if you need to use built-in navigation mechanism (Navigator). Since Dartea Program.build() creates native Flutter widget we can use it easily with Navigator. Here is example of such router. Here we do not create root model for pages, instead we create new Program for each page. And this fine for Flutter. Every program instance is native Flutter widget and we can do everything that we can do with all the other widgets.

All this two approaches can be combined together in one app. This example of ToDo app is good place to find out how to apply both approaches.

Please reply if it's still unclear, then I'll try to create one more sample.

@puruzio
Copy link
Author

puruzio commented Sep 12, 2018

Thanks so much for your thoughtful response!

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

2 participants