Skip to content

Commit

Permalink
-ItemBuilder is used to loop through items
Browse files Browse the repository at this point in the history
item is a index for list
-odd item creates divider
-we add to the existing pair of words at end  of list for scrolling
  • Loading branch information
nidhidsharma08121988 committed Nov 23, 2023
1 parent 09eb6ec commit 9c9e12d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class MyApp extends StatelessWidget {

return ListView.builder(
padding: const EdgeInsets.all(16),
itemBuilder: (context, item) {
if (item.isOdd) {
return const Divider();
}

final index = item ~/ 2;

if (index >= randomWordPairs.length) {
randomWordPairs.addAll(generateWordPairs().take(10));
}
);
});
}
Expand Down

0 comments on commit 9c9e12d

Please sign in to comment.