Skip to content

Swiping on a listview under perspective can cause erratic behaviour #154104

@FufferKS

Description

@FufferKS

Steps to reproduce

Have a ListView under a Transform with a perspective that imitates a "road".
If you swipe your finger outside of the visible bounds of the list, the list jumps to an unpredictable location, in a direction opposite to that of a swipe.

Expected results

The list should behave "normally".

Actual results

The list jumps to an unpredictable location.

Code sample

Code sample
import 'package:flutter/material.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,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  final _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Transform(
        transform: Matrix4.identity()..setEntry(3, 1, -0.003),
        alignment: Alignment.bottomCenter,
        child: ListView.builder(
          controller: _scrollController,
          physics: const ClampingScrollPhysics(),
          reverse: true,
          itemBuilder: (context, index) => Container(
            color: index.isEven ? Colors.white : Colors.black12,
            alignment: Alignment.center,
            child: Text('Item $index'),
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        tooltip: 'Reset To Start of the List',
        onPressed: () => _scrollController.animateTo(
          0,
          duration: const Duration(seconds: 1),
          curve: Curves.easeInOut,
        ),
        child: const Icon(Icons.backspace_sharp),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2024-08-26.at.11.50.31.mov

Logs

Logs
Nothing in the logs when this happens

Flutter Doctor output

(Flutter version should not matter, we've had this for a long time.)

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-arm64, locale en-PL)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Community Edition (version 2023.2.1)
[✓] VS Code (version 1.92.1)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectf: scrollingViewports, list views, slivers, etc.found in release: 3.24Found to occur in 3.24found in release: 3.25Found to occur in 3.25frameworkflutter/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