0
0
Fluttermobile~10 mins

Infinite scrolling in Flutter - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a scroll controller for infinite scrolling.

Flutter
final ScrollController [1] = ScrollController();
Drag options to blanks, or click blank then click option'
AscrollController
BscrollCtrl
Ccontroller
DlistController
Attempts:
3 left
💡 Hint
Common Mistakes
Using vague or unrelated variable names.
Forgetting to declare the ScrollController.
2fill in blank
medium

Complete the code to add a listener to the scroll controller.

Flutter
scrollController.[1](() {
  if (scrollController.position.pixels == scrollController.position.maxScrollExtent) {
    // Load more items
  }
});
Drag options to blanks, or click blank then click option'
AonScroll
BaddListener
Clisten
DaddScrollListener
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'onScroll' or 'listen'.
Forgetting to add the listener.
3fill in blank
hard

Fix the error in the code to check if the user scrolled to the bottom.

Flutter
if (scrollController.position.[1] == scrollController.position.maxScrollExtent) {
  fetchMoreData();
}
Drag options to blanks, or click blank then click option'
Aposition
Boffset
Cextent
Dpixels
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'offset' or 'position' which are not valid properties here.
Confusing 'extent' with current position.
4fill in blank
hard

Fill both blanks to create a ListView with infinite scrolling using the scroll controller.

Flutter
ListView.builder(
  controller: [1],
  itemCount: items.length + 1,
  itemBuilder: (context, index) {
    if (index == items.length) {
      return [2];
    }
    return ListTile(title: Text(items[index]));
  },
)
Drag options to blanks, or click blank then click option'
AscrollController
BCircularProgressIndicator()
Cnull
DScrollController()
Attempts:
3 left
💡 Hint
Common Mistakes
Creating a new ScrollController inside the ListView.
Returning null instead of a loading widget.
5fill in blank
hard

Fill all three blanks to dispose the scroll controller properly in a StatefulWidget.

Flutter
@override
void [1]() {
  [2].dispose();
  super.[3]();
}
Drag options to blanks, or click blank then click option'
Adispose
BscrollController
DinitState
Attempts:
3 left
💡 Hint
Common Mistakes
Calling dispose on the wrong object.
Forgetting to call super.dispose().