flutter_sortable_wrap 1.0.2 copy "flutter_sortable_wrap: ^1.0.2" to clipboard
flutter_sortable_wrap: ^1.0.2 copied to clipboard

outdated

A Reorder/Sort Wrap Widget. Written with pure dart, supported both iOS/Android/Web and Macos/Linux/Windows.

example/lib/main.dart

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

void main() {
  runApp(App());
}

class App extends StatefulWidget {
  @override
  AppState createState() => AppState();
}

class AppState extends State<App> {
  List<int> array = [];

  @override
  void initState() {
    super.initState();

    array.clear();
    for (int i = 0; i < 21; i++) array.add(i);
  }

  @override
  Widget build(BuildContext context) {
    iDebugLog('App rebuild!!!!');
    Color alphaColor(Color color, {int alpha = 64}) => color.withAlpha(alpha);
    Widget boxText(String text) => SizedBox(width: 72, height: 72, child: Center(child: Text(text)));
    List<Color> colors = [
      Colors.redAccent,
      Colors.blueAccent,
      Colors.pinkAccent,
      Colors.greenAccent,
      Colors.amberAccent,
      Colors.purpleAccent,
    ];
    colors = colors.map((e) => alphaColor(e)).toList();
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SafeArea(
          child: Container(
            alignment: Alignment.topCenter,
            color: Colors.white.withAlpha(64),
            child: SortableWrap(
              children: [
                for (int i = 0; i < array.length; i++) ColoredBox(color: colors[array[i] % colors.length], child: boxText('${array[i]}')),
              ],
              onSorted: (int oldIndex, int newIndex) {
                setState(() {
                  array.insert(newIndex, array.removeAt(oldIndex));
                  iDebugLog('=======>>>>> array: $array');
                });
              },
              spacing: 10,
              runSpacing: 15,
            ),
          ),
        ),
      ),
    );
  }
}
26
likes
0
points
250
downloads

Publisher

unverified uploader

Weekly Downloads

A Reorder/Sort Wrap Widget. Written with pure dart, supported both iOS/Android/Web and Macos/Linux/Windows.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_sortable_wrap