positioned_scroll_observer 1.0.0 copy "positioned_scroll_observer: ^1.0.0" to clipboard
positioned_scroll_observer: ^1.0.0 copied to clipboard

An elegant scroll observer that support all official slivers. You could use this package to jump/animateToIndex for your SliverList/Grid without breaking your current widgets. Just wrap your item widg [...]

example/lib/main.dart

import 'package:flutter/material.dart';

import 'example/examples.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Indexed Scroll Observer Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            OutlinedButton(
              onPressed: () {
                context.push(
                  const OfficialListExample(),
                );
              },
              child: const Text("List view Usage"),
            ),
            OutlinedButton(
              onPressed: () {
                context.push(
                  const OfficialReorderableListExample(),
                );
              },
              child: const Text("Reorderable List Usage"),
            ),
            OutlinedButton(
              onPressed: () {
                context.push(
                  const OfficialSeparatedListExample(),
                );
              },
              child: const Text("Separated List Usage"),
            ),
            OutlinedButton(
              onPressed: () {
                context.push(const PositionedGridExample());
              },
              child: const Text("Encapsulated Grid Usage"),
            ),
            OutlinedButton(
              onPressed: () {
                context.push(const CustomViewExample());
              },
              child: const Text("Encapsulated CustomScrollView Usage"),
            ),
          ],
        ),
      ),
    );
  }
}

extension Navigation on BuildContext {
  void push(Widget page) {
    Navigator.of(this).push(
      MaterialPageRoute(builder: (_) => page),
    );
  }
}
22
likes
0
points
2.3k
downloads

Publisher

verified publishersimonwang.dev

Weekly Downloads

An elegant scroll observer that support all official slivers. You could use this package to jump/animateToIndex for your SliverList/Grid without breaking your current widgets. Just wrap your item widgets using [ObserverProxy] and setup a [ScrollObserver] for them, the you go.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on positioned_scroll_observer