scroll_restoration 0.0.3
scroll_restoration: ^0.0.3 copied to clipboard
A Flutter widget that automatically saves and restores scroll positions for any scrollable widget.
Scroll Restoration #
- Inspired by scroll_restore
Features #
Automatically saves and restores the scroll position of any scrollable widget.
Usage #
Wrap your scrollable in ScrollRestoration, giving it a unique id:
class MyScreen extends StatelessWidget {
List<String> get items => List.generate(200, (i) => '$i');
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('My Screen')),
body: ScrollRestoration(
id: 'my_restorable_list_id', // unique key per scrollable
builder: (context, controller) {
return ListView.builder(
controller: controller,
itemCount: items.length,
itemBuilder: (_, index) {
return ListTile(
title: Text(items[index]),
);
},
);
},
),
);
}
}