csells / go_router

The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
https://gorouter.dev
441 stars 97 forks source link

Deferred route on web #113

Closed jaumard closed 3 years ago

jaumard commented 3 years ago

I read that best practice for flutter web is to use deferred import to optimize loading time.

I was wondering if there is any exemple of how it work with go_router, I was expecting a GoDeferredRoute

csells commented 3 years ago

Can you point me at that guidance?

jaumard commented 3 years ago

Sure! Here is a medium article that talk about this https://medium.com/flutter/optimizing-performance-in-flutter-web-apps-with-tree-shaking-and-deferred-loading-535fbe3cd674

Official docs mention it here https://flutter.dev/docs/perf/deferred-components but not dedicated to flutter web.

Would be awesome to have GODeferredRoute that take care of loading the deferred component to improve loading time.

csells commented 3 years ago

I'm open to a PR for sure.

csells commented 3 years ago

Although in thinking about it more, if your pages are deferred types, then it should just work, right?

jaumard commented 3 years ago

Deferred types mean that before you can use it you need to load it, so it's a async process. So it need to be taking care in some way or it doesn't work, to be honest I didn't make any testing about this yet. And I just start building for web so I was searching for some examples ^^

csells commented 3 years ago

To load the page types asynchronously, I'd use a pattern like the one described here: https://pub.dev/packages/go_router#async-data