Skip to content
Alessandro Autiero
Go back

Flutter Web Engine: Make the html page adapt to the canvas' size instead of hiding it

Hello, I want to propose a change to the Flutter Web Engine in order to make scrolling easier and smoother.

The current implementation doesn’t take into consideration that HTML pages, unlike Android, IOS or Desktop platforms, adapt to the size of the content that it’s displaying. Because of this, when using a Scrollable widget, like a ListView, instead of letting the page adapt to the content of the scrollable widget and letting the browser handle scrolling as it would for any normal page, Flutter Web hides the overflow and handles internally scrolling using translations and offsets. You can find below what flutter web does right now visually, the red rectangle is the browser’s viewport. For the browser, because the page isn’t scrollable, only what is in the viewport exists. When the user scrolls, flutter web adds the needed widgets to the DOM and simulates scrolling using offsets and transformations. Illustration

Obviously, this introduces a lot of lag and makes it impossible to have the native scrolling bar next to the page.

What I’m proposing is to modify the engine and let the browser handle scrolling natively for scrollable widgets if their size is known, for example, this is not the case for a ListView.builder that doesn’t specify its itemCount.


Originally opened as a GitHub issue, flutter/flutter#64501, on August 24, 2020.



Next Post
Some features I'd like to see in feature Java releases