As you have seen in this recipe, creating scrollable widgets in Flutter is easy. There is only one method that creates a scrolling widget and that method is tiny. Scrolling in Flutter is just a simple matter of choosing the correct widget and passing your data. The framework takes care of the rest.
Let's break down the scrolling code that is in this recipe:
Widget _buildLapDisplay() {
return ListView(
children: [
for (int milliseconds in laps)
ListTile(
title: Text(_secondsText(milliseconds)),
)
],
);
}
We're using a type of scrolling widget called ListView, which is probably one of the simplest types of scrolling widgets in Flutter. This widget functions a bit like a column, except instead of throwing errors when it runs out of space, ListView will enable scrolling, allowing you to use drag gestures to scroll through all the data.
In our example, we're also using the collection-for syntax...