Search code examples
flutterweb-applicationslazy-loading

Is there a way to load pages in a flutter webapp only when they are needed?


I am trying to make a flutter webapp more performant and the only solution I can think of is to load the webpages lazily. Is there a way to do this in Flutter?

I tried using regular navigation but the webapp lagged heavily on some lower end devices when testing.


Solution

  • See https://dart.dev/language/libraries under Lazily loading a library. It takes some work on your part, but you can lazily load any portion of your app.

    Deferred loading (also called lazy loading) allows a web app to load a library on demand, if and when the library is needed. Here are some cases when you might use deferred loading: To reduce a web app’s initial startup time. To perform A/B testing—trying out alternative implementations of an algorithm, for example. To load rarely used functionality, such as optional screens and dialogs.