Complete the code to create a ListView using ListView.builder.
ListView.builder( itemCount: 10, itemBuilder: (context, index) { return Text('Item ${index}'); }, [1]: true, )
The shrinkWrap property tells the ListView to size itself based on its children. Setting it to true is common when ListView is inside another scrollable widget.
Complete the code to set the scroll direction of the ListView to horizontal.
ListView.builder( itemCount: 5, itemBuilder: (context, index) => Text('Item ${index}'), [1]: Axis.horizontal, )
The scrollDirection property controls the direction in which the ListView scrolls. Setting it to Axis.horizontal makes the list scroll sideways.
Fix the error in the itemBuilder function to correctly return a ListTile widget.
ListView.builder( itemCount: 3, itemBuilder: (context, index) { return [1]( title: Text('Title ${index}'), ); }, )
The itemBuilder must return a widget. Here, ListTile is the correct widget to display a title in a list.
Fill both blanks to create a ListView.builder that shows 4 items with a blue background color.
ListView.builder( itemCount: [1], itemBuilder: (context, index) { return Container( color: [2], child: Text('Item ${index}'), ); }, )
The itemCount should be 4 to show four items. The color property is set to Colors.blue to give a blue background.
Fill all three blanks to create a ListView.builder that shows uppercase item titles with 6 items and a green background.
ListView.builder( itemCount: [1], itemBuilder: (context, index) { return Container( color: [2], child: Text('Item ${index}'.[3]()), ); }, )
Set itemCount to 6 to show six items. The container color is Colors.green. The text is converted to uppercase using toUpperCase().