smooth_list_view 2.0.0 copy "smooth_list_view: ^2.0.0" to clipboard
smooth_list_view: ^2.0.0 copied to clipboard

ListView constructors that implement smooth scrolling when using a mouse and scrolling with arrow keys.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:smooth_list_view/smooth_list_view.dart';

const List<Color> colorList = [Colors.red, Colors.blue, Colors.green];

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool smooth = false;
  late ScrollController controller;

  @override
  void initState() {
    super.initState();
    controller = ScrollController();
  }

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      showPerformanceOverlay: false,
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: LayoutBuilder(
          builder: (BuildContext context, BoxConstraints constraints) {
            return Center(
              child: SizedBox(
                width: constraints.maxWidth * 0.8,
                height: constraints.maxHeight * 0.8,
                child: SmoothListView.builder(
                  smoothScroll: smooth,
                  duration: const Duration(milliseconds: 200),
                  controller: controller,
                  itemCount: 20,
                  itemBuilder: (ctx, idx) {
                    return ListTile(
                      textColor: colorList[idx % colorList.length],
                      onTap: () => debugPrint("pressed $idx"),
                      title: Text("$idx"),
                    );
                  },
                ),
              ),
            );
          },
        ),
        floatingActionButton: FloatingActionButton(
          child: Icon(smooth ? Icons.toggle_on : Icons.toggle_off),
          onPressed: () {
            setState(() {
              smooth = !smooth;
            });
          },
        ),
      ),
    );
  }
}
25
likes
0
points
290
downloads

Publisher

unverified uploader

Weekly Downloads

ListView constructors that implement smooth scrolling when using a mouse and scrolling with arrow keys.

Repository (GitHub)
View/report issues

Topics

#animation #ui #widget #web

License

unknown (license)

Dependencies

flutter

More

Packages that depend on smooth_list_view