Skip to content

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

Open

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!

Activity

  1. danagbemava-nc commented on Aug 27, 2024

    @danagbemava-nc
    Member

    Reproducible using the code sample provided above.

    flutter doctor -v
    [!] Flutter (Channel stable, 3.24.1, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
        • Flutter version 3.24.1 on channel stable at /Users/deanli/dev/stable
        ! The flutter binary is not on your path. Consider adding /Users/deanli/dev/stable/bin to your path.
        ! The dart binary is not on your path. Consider adding /Users/deanli/dev/stable/bin to your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 5874a72aa4 (6 days ago), 2024-08-20 16:46:00 -0500
        • Engine revision c9b9d5780d
        • Dart version 3.5.1
        • DevTools version 2.37.2
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [!] Flutter (Channel master, 3.25.0-1.0.pre.147, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
        • Flutter version 3.25.0-1.0.pre.147 on channel master at /Users/deanli/dev/master
        ! The flutter binary is not on your path. Consider adding /Users/deanli/dev/master/bin to your path.
        ! The dart binary is not on your path. Consider adding /Users/deanli/dev/master/bin to your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 99dc3beaf4 (6 hours ago), 2024-08-26 22:10:32 -0400
        • Engine revision b41ca79092
        • Dart version 3.6.0 (build 3.6.0-175.0.dev)
        • DevTools version 2.39.0-dev.15
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: scrollingViewports, list views, slivers, etc.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Aug 27, 2024
  3. added
    P3Issues that are less important to the Flutter project
    on Aug 28, 2024
  4. Piinks commented on Aug 28, 2024

    @Piinks
    Contributor

    This is likely because the transform also affects the coordinate plane the gesture is being applied to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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