Step 4: Ininite scrolling list
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
de2e14fc3e
commit
efbb99b3c2
|
@ -41,9 +41,27 @@ class _RandomWordsState extends State<RandomWords> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final wordPair = WordPair.random();
|
final wordPair = WordPair.random();
|
||||||
|
|
||||||
|
return ListView.builder(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
itemBuilder: /*1*/ (context, i) {
|
||||||
|
if (i.isOdd) return const Divider(); /*2*/
|
||||||
|
|
||||||
|
final index = i ~/ 2; /*3*/
|
||||||
|
if (index >= _suggestions.length) {
|
||||||
|
_suggestions.addAll(generateWordPairs().take(10)); /*4*/
|
||||||
|
}
|
||||||
|
return Text(
|
||||||
|
_suggestions[index].asPascalCase,
|
||||||
|
style: TextStyle(fontSize: 36, fontWeight: FontWeight.bold)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
return Text(
|
return Text(
|
||||||
wordPair.asPascalCase,
|
wordPair.asPascalCase,
|
||||||
style: TextStyle(fontSize: 48, fontWeight: FontWeight.bold)
|
style: TextStyle(fontSize: 48, fontWeight: FontWeight.bold)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue