flutter_list_view 0.1.1
flutter_list_view: ^0.1.1 copied to clipboard
Provide enhanced list view include jump index, keep position etc.
Flutter List View #
I don't like official list view. There are some features don't provide and jumpTo performance is not good. I rewrite the list supported these features in [Features] sections
Features #
- Support jump to index Jump to index is not support in listview. But it is useful function
- Support keep position If some data insert before other items, It will scroll down. Some chat software may want to keep the position not scroll down when new message coming.
- Support show top in reverse mode if the data can't fill full viewport.
- Performance When listview jump to somewhere, The items which layout before the position will always loaded. It is not realy lazy loading.
Screen #
Example #
CustomScrollView(
reverse: reverse,
slivers: [
FlutterListView(
controller: flutterListViewController,
delegate: FlutterListViewDelegate(
(BuildContext context, int index) => Container(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text('List Item ${data[index]}'),
),
),
childCount: data.length,
)),
],
),
Jump to index #
flutterListViewController.jumpToIndex(100);
OR
/// Declare
FlutterListViewController flutterListViewController = FlutterListViewController();
...
flutterListViewController.jumpToIndex(
100,
offset: 100,
offsetBasedOnBottom: true);
Keep Position #
CustomScrollView(
reverse: reverse,
slivers: [
FlutterListView(
controller: flutterListViewController,
delegate: FlutterListViewDelegate(
(BuildContext context, int index) => Container(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text('List Item ${data[index]}'),
),
),
childCount: data.length,
onItemKey: (index) => data[index].toString(),
keepPosition: true,
keepPositionOffset: 80)),
],
),