flutterdartreorderable-list

Flutter: Why is my ReorderableList not registering my drag?


import 'package:flutter/material.dart';

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

  @override
  Widget build(BuildContext context) {
    return ReorderableList(
      onReorder: (oldIndex, newIndex) {},
      itemBuilder: (context, index) => Padding(
        key: ValueKey(index),
        padding: const EdgeInsets.all(10),
        child: const ListTile(
          title: Text("hey!"),
          contentPadding: EdgeInsets.symmetric(vertical: 20, horizontal: 20),
          tileColor: Colors.green,
        ),
      ),
      itemCount: 5,
    );
  }
}

I have made this ChatPage just to test the results in a super easy, not conflicting with anything, way, but my drag is not detected and i can't reorder my list!

I know the "onReorder" is not filled out, so it would not save my changes, but I cant drag the tiles at all:/

Thank you!


Solution

  • Does something speak against using ReorderableListView.builder?

    ReorderableListView.builder(
        onReorder: (oldIndex, newIndex) {},
        itemBuilder: (context, index) => Padding(
          key: ValueKey(index),
          padding: const EdgeInsets.all(10),
          child: const ListTile(
            title: Text("hey!"),
            contentPadding:
                EdgeInsets.symmetric(vertical: 20, horizontal: 20),
            tileColor: Colors.green,
          ),
        ),
        itemCount: 5,
      );