I am learning the Flutter framework and want to ask about the first example app from google tutorials. Namely, I wonder how this code really works.
Widget _buildSuggestions() {
return new ListView.builder(
padding: new EdgeInsets.all(6.0),
itemBuilder: (_, int i) {
if (i.isOdd)
return new Divider(
height: 1.0,
);
final int index = i ~/ 2;
print(index);
print('sug leng ${_suggestions.length}');
if (index >= _suggestions.length) {
_suggestions.addAll(generateWordPairs().take(10));
}
return _buildRow(_suggestions[index]);
});
}
How the words are really generated. Like when I inspect the index and the length of _suggestions it's saying that I've generated 20 words but the index is 14 when I slide down the index is moving up and at some point, the new words are added. How it detects when to add and when to stop counting the index? If someone can briefly explain to me this I would appreciate!! Thanks!