scroll_restoration 0.0.3 copy "scroll_restoration: ^0.0.3" to clipboard
scroll_restoration: ^0.0.3 copied to clipboard

A Flutter widget that automatically saves and restores scroll positions for any scrollable widget.

Scroll Restoration #

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]),
              );
            },
          );
        },
      ),
    );
  }
}
1
likes
150
points
216
downloads

Publisher

verified publishermj12358.dev

Weekly Downloads

A Flutter widget that automatically saves and restores scroll positions for any scrollable widget.

Repository (GitHub)

Topics

#flutter #widget

Documentation

API reference

Funding

Consider supporting this project:

www.buymeacoffee.com

License

BSD-3-Clause (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on scroll_restoration