Skip to content

Children of SliverCrossAxisGroup report incorrect gestures' localPosition. #174262

@ksokolovskyi

Description

@ksokolovskyi

Steps to reproduce

  1. Run the code sample
  2. Tap on the 0 item (the local and global dx values are equal, and this is correct, as the item is the leftmost)
  3. Tap on the left side of the 1 or 2 item (the local and global dx values are equal, which is incorrect; the local dx value has to have a value near 0)

Expected results

The local position of the gesture for each child of SliverCrossAxisGroup is correct.

Actual results

The local position of the gesture for each child of SliverCrossAxisGroup is incorrect.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const App());
}

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

  @override
  Widget build(BuildContext context) {
    Widget buildItem(int index) {
      return SliverToBoxAdapter(
        child: GestureDetector(
          behavior: HitTestBehavior.opaque,
          onTapDown: (TapDownDetails details) {
            print('[#$index item global] ${details.globalPosition}');
            print('[#$index item local] ${details.localPosition}');
            print('');
          },
          child: ColoredBox(
            color: Colors.blue[(index + 1) * 200]!,
            child: SizedBox(
              height: 100,
              child: Center(
                child: Text('$index'),
              ),
            ),
          ),
        ),
      );
    }

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('SliverCrossAxisGroup')),
        body: CustomScrollView(
          slivers: <Widget>[
            SliverCrossAxisGroup(
              slivers: <Widget>[
                buildItem(0),
                buildItem(1),
                buildItem(2),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
sliver_cross_axis_group_bug.mov

Flutter Doctor output

Doctor output
[✓] Flutter (Channel master, 3.35.0-1.0.pre-551, on macOS 15.6 24G84 darwin-arm64, locale en-US)
    [2.2s]
    • Flutter version 3.35.0-1.0.pre-551 on channel master at
      /Users/ksokolovskyi/development/flutter_master
    • Upstream repository [email protected]:ksokolovskyi/flutter.git
    • FLUTTER_GIT_URL = [email protected]:ksokolovskyi/flutter.git
    • Framework revision 47b253fdeb (10 hours ago), 2025-08-21 21:50:27 -0400
    • Engine revision 47b253fdeb
    • Dart version 3.10.0 (build 3.10.0-125.0.dev)
    • DevTools version 2.49.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop,
      enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file,
      enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [2.9s]
    • Android SDK at /Users/ksokolovskyi/Library/Android/sdk
    • Emulator version 35.4.9.0 (build_id 13025442) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • ANDROID_HOME = /Users/ksokolovskyi/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [964ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [5ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (2 available) [6.1s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 15.6 24G84 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 139.0.7258.139

[✓] Network resources [1,752ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

f: gesturesflutter/packages/flutter/gestures repository.f: scrollingViewports, list views, slivers, etc.found in release: 3.32Found to occur in 3.32found in release: 3.35Found to occur in 3.35frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions