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

Drag-to-reorder Wrap, lazy grid, table, Row and Column with animated displacement, auto-scroll, drag handles, RTL and accessibility actions.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'demos/column_demo.dart';
import 'demos/grid_demo.dart';
import 'demos/row_demo.dart';
import 'demos/table_demo.dart';
import 'demos/wrap_demo.dart';
import 'settings.dart';

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

/// The example app.
class DemoApp extends StatefulWidget {
  /// Creates the app.
  const DemoApp({super.key});

  @override
  State<DemoApp> createState() => _DemoAppState();
}

class _DemoAppState extends State<DemoApp> {
  final DemoSettings settings = DemoSettings();

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

  @override
  Widget build(BuildContext context) {
    return ListenableBuilder(
      listenable: settings,
      builder: (context, _) => MaterialApp(
        title: 'reorderable_wrap',
        theme: ThemeData(colorSchemeSeed: Colors.indigo, useMaterial3: true),
        builder: (context, child) => Directionality(
          textDirection: settings.rtl ? TextDirection.rtl : TextDirection.ltr,
          child: child!,
        ),
        home: DemoSettingsScope(settings: settings, child: const HomePage()),
      ),
    );
  }
}

/// Lists the demos.
class HomePage extends StatelessWidget {
  /// Creates the home page.
  const HomePage({super.key});

  static final List<(String, String, WidgetBuilder)> demos = [
    (
      'ReorderableWrap',
      'Tags of different widths, multi-line',
      (_) => const WrapDemo()
    ),
    (
      'ReorderableGridView',
      'Lazy grid of 200 tiles, auto-scroll',
      (_) => const GridDemo()
    ),
    (
      'ReorderableTable',
      'Rows move, columns stay aligned',
      (_) => const TableDemo()
    ),
    ('ReorderableRow', 'Horizontal, non-scrolling', (_) => const RowDemo()),
    (
      'ReorderableColumn',
      'Handles and a pinned item',
      (_) => const ColumnDemo()
    ),
  ];

  @override
  Widget build(BuildContext context) {
    final settings = DemoSettingsScope.of(context);
    return Scaffold(
      appBar: AppBar(title: const Text('reorderable_wrap')),
      body: ListView(
        children: [
          for (final (title, subtitle, builder) in demos)
            ListTile(
              title: Text(title),
              subtitle: Text(subtitle),
              trailing: const Icon(Icons.chevron_right),
              onTap: () => Navigator.of(context).push(MaterialPageRoute<void>(
                builder: (_) => DemoSettingsScope(
                    settings: settings, child: Builder(builder: builder)),
              )),
            ),
          const Divider(),
          const SettingsPanel(),
        ],
      ),
    );
  }
}

/// Shows the index convention after each reorder.
void showMove(BuildContext context, int oldIndex, int newIndex) {
  ScaffoldMessenger.of(context)
    ..hideCurrentSnackBar()
    ..showSnackBar(SnackBar(
      content: Text('onReorder($oldIndex, $newIndex)'),
      duration: const Duration(milliseconds: 900),
    ));
}
0
likes
150
points
55
downloads

Documentation

API reference

Publisher

verified publisherabdeldjalilchougui.biz

Weekly Downloads

Drag-to-reorder Wrap, lazy grid, table, Row and Column with animated displacement, auto-scroll, drag handles, RTL and accessibility actions.

Homepage
Repository (GitHub)
View/report issues

Topics

#reorderable #drag-and-drop #wrap #grid #widget

License

MIT (license)

Dependencies

flutter

More

Packages that depend on reorderable_wrap