flutter_drag_auto_scroll 0.1.0 copy "flutter_drag_auto_scroll: ^0.1.0" to clipboard
flutter_drag_auto_scroll: ^0.1.0 copied to clipboard

Auto-scroll any vertically scrollable widget when a Draggable enters its top or bottom edge zones. Supports same-tree and cross-tree usage.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'demos/playlist_demo.dart';
import 'demos/task_board_demo.dart';
import 'playground.dart';

void main() => runApp(const ExampleApp());

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

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  ThemeMode _themeMode = ThemeMode.system;

  void _toggleTheme() {
    setState(() {
      final brightness = _themeMode == ThemeMode.system
          ? WidgetsBinding.instance.platformDispatcher.platformBrightness
          : (_themeMode == ThemeMode.dark ? Brightness.dark : Brightness.light);
      _themeMode = brightness == Brightness.dark
          ? ThemeMode.light
          : ThemeMode.dark;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'flutter_drag_auto_scroll',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(colorSchemeSeed: Colors.indigo, useMaterial3: true),
      darkTheme: ThemeData(
        colorSchemeSeed: Colors.indigo,
        brightness: Brightness.dark,
        useMaterial3: true,
      ),
      themeMode: _themeMode,
      home: HomeShell(onToggleTheme: _toggleTheme),
    );
  }
}

class HomeShell extends StatefulWidget {
  const HomeShell({super.key, required this.onToggleTheme});

  final VoidCallback onToggleTheme;

  @override
  State<HomeShell> createState() => _HomeShellState();
}

class _HomeShellState extends State<HomeShell> {
  int _index = 0;

  static const _pages = [PlaylistDemo(), TaskBoardDemo(), Playground()];

  @override
  Widget build(BuildContext context) {
    final isDark = Theme.of(context).brightness == Brightness.dark;
    return Scaffold(
      body: SafeArea(
        child: Row(
          children: [
            NavigationRail(
              selectedIndex: _index,
              onDestinationSelected: (i) => setState(() => _index = i),
              labelType: NavigationRailLabelType.all,
              trailing: Expanded(
                child: Align(
                  alignment: Alignment.bottomCenter,
                  child: Padding(
                    padding: const EdgeInsets.only(bottom: 16),
                    child: IconButton(
                      tooltip: isDark ? 'Light mode' : 'Dark mode',
                      onPressed: widget.onToggleTheme,
                      icon: Icon(
                        isDark
                            ? Icons.light_mode_outlined
                            : Icons.dark_mode_outlined,
                      ),
                    ),
                  ),
                ),
              ),
              destinations: const [
                NavigationRailDestination(
                  icon: Icon(Icons.queue_music_outlined),
                  selectedIcon: Icon(Icons.queue_music),
                  label: Text('Playlist'),
                ),
                NavigationRailDestination(
                  icon: Icon(Icons.space_dashboard_outlined),
                  selectedIcon: Icon(Icons.space_dashboard),
                  label: Text('Sprint'),
                ),
                NavigationRailDestination(
                  icon: Icon(Icons.tune_outlined),
                  selectedIcon: Icon(Icons.tune),
                  label: Text('Playground'),
                ),
              ],
            ),
            const VerticalDivider(width: 1),
            Expanded(child: _pages[_index]),
          ],
        ),
      ),
    );
  }
}
2
likes
160
points
66
downloads
screenshot

Documentation

API reference

Publisher

verified publishermaibornwolff.de

Weekly Downloads

Auto-scroll any vertically scrollable widget when a Draggable enters its top or bottom edge zones. Supports same-tree and cross-tree usage.

Repository (GitHub)
View/report issues

Topics

#drag-and-drop #scrolling #draggable #ui

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_drag_auto_scroll