Skip to content

ReorderableListView.builder in Horizontal moves last item into view when dragging #135819

@JerContact

Description

@JerContact

Is there an existing issue for this?

Steps to reproduce

  1. Run the code below
  2. Resize the window to the image provided (make sure to Resize it properly)
  3. Make sure only 3 of the 4 widgest are visible, like the image provided
  4. Drag the first "Test" widget
  5. Notice when you start to drag, even though the 4th widget isn't on the screen, it moves into view over thte 3rd widget text. So you see "Something" over "Good"

Expected results

  1. When dragging, things farther in the view shouldn't glitch over into view

Actual results

  1. Widgets move from outside the viewport into view

Code sample

Code sample
import 'dart:math' as math;

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      scrollBehavior: const MaterialScrollBehavior().copyWith(
        // Mouse dragging enabled for this demo
        dragDevices: PointerDeviceKind.values.toSet(),
      ),
      debugShowCheckedModeBanner: false,
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

  const MyHomePage({
    Key? key,
    required this.title,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    List<String> items = ['Test', 'Bad', 'Good', 'Something'];
    return Scaffold(
      appBar: AppBar(title: Text(title)),
      body: ReorderableListView.builder(
        proxyDecorator: (child, index, animation) {
          return Container(
            decoration: BoxDecoration(
              color: Colors.black26,
              borderRadius: BorderRadius.circular(10.0),
              border: Border.all(
                color: Colors.white10,
                width: 2.0,
              ),
            ),
            child: SizedBox(
              width: 500,
              child: child,
            ),
          );
        },
        buildDefaultDragHandles: false,
        scrollDirection: Axis.horizontal,
        itemCount: 4,
        onReorder: (oldIndex, newIndex) {},
        itemBuilder: (context, i) => ReorderableDragStartListener(
          key: ValueKey(i),
          index: i,
          child: GestureDetector(
            onSecondaryTap: null,
            child: SizedBox(
              width: 500,
              child: TextButton(
                onPressed: null,
                child: Row(
                  children: [
                    Text(
                      items[i],
                    ),
                  ],
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

flutter_glitch

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.13.3, on Microsoft Windows [Version 10.0.22621.2134], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.7.3)
[√] Android Studio (version 2021.3)
[√] VS Code (version 1.82.2)
[√] Connected device (3 available)
[√] Network resources

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: renderingUI glitches reported at the engine/skia or impeller rendering levelf: scrollingViewports, list views, slivers, etc.found in release: 3.13Found to occur in 3.13found in release: 3.15Found to occur in 3.15frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions