Skip to content

SliverReorderableList can not reorder on Android platform #103404

Description

@xu-baolin

Code

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

void main() {
  debugPrintGestureArenaDiagnostics = true;
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final List<int> _items = List<int>.generate(5, (int index) => index);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverReorderableList(
            itemCount: _items.length,
            itemBuilder: (context, index) {
              print(index);

              return ReorderableDragStartListener(
                index: index,
                key: Key('$index'),
                child: Container(
                  color: Colors.red,
                  padding: const EdgeInsets.all(40.0),
                  child: Text(_items[index].toString()),
                ),
              );
            },
            onReorder: (int oldIndex, int newIndex) {
              setState(() {
                if (oldIndex < newIndex) {
                  newIndex -= 1;
                }

                final int item = _items.removeAt(oldIndex);
                _items.insert(newIndex, item);
              });
            },
          ),
        ],
      ),
    );
  }
}

Activity

  1. added
    c: regressionIt was better in the past than it is now
    platform-androidAndroid applications specifically
    P1High-priority issues at the top of the work list
    on May 10, 2022
  2. self-assigned this
    on May 10, 2022
  3. jonahwilliams commented on May 12, 2022

    @jonahwilliams
    Contributor

    Adding to the cherry-pick review queue since I think this will be a particularly surprising issue for folks, and because the fix is simple and low risk

  4. github-actions commented on May 26, 2022

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: regressionIt was better in the past than it is nowcp: reviewCherry-picks in the review queueplatform-androidAndroid applications specifically

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions