Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SliverMainAxisGroup in a reverse scroll view doesn't work as expected #149094

Closed
jellynoone opened this issue May 25, 2024 · 2 comments
Closed

SliverMainAxisGroup in a reverse scroll view doesn't work as expected #149094

jellynoone opened this issue May 25, 2024 · 2 comments
Labels
r: fixed Issue is closed as already fixed in a newer version

Comments

@jellynoone
Copy link
Contributor

Steps to reproduce

  1. Copy code sample
  2. Run
  3. Click on items in the last column titled (Reversed with prefix)
  4. Observe the next item below the clicked one being activated

Expected results

The item clicked should be the one to active

Actual results

Items in the "Reversed with prefix" column, are activated out of sync.

Items in "Reversed" column, don't have this problem. Which seems to indicate, whenever there is a sliver preceding a SliverMainAxisGroup, it will affect how the group handles gestures.

Code sample

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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MainAxisReverseGroupGestures(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    final colors = SliverList.list(children: const [
      _Box(color: Colors.pink),
      _Box(color: Colors.green),
      _Box(color: Colors.teal),
    ]);
    const prefix = SliverToBoxAdapter(
      child: ColoredBox(
        color: Colors.grey,
        child: SizedBox(height: 100),
      ),
    );
    Widget current = Row(children: [
      _TestCase(title: 'Regular', reverse: false, slivers: [
        colors,
      ]),
      const SizedBox(width: 2),
      _TestCase(title: 'Regular with prefix', reverse: false, slivers: [
        prefix,
        colors,
      ]),
      const SizedBox(width: 2),
      _TestCase(title: 'Reversed', reverse: true, slivers: [
        colors,
      ]),
      const SizedBox(width: 2),
      // Clicking on items from this list doesn't work as expected
      _TestCase(title: 'Reversed with prefix', reverse: true, slivers: [
        prefix,
        colors,
      ]),
    ]);
    current = Scaffold(
      body: current,
    );
    return current;
  }
}

class _TestCase extends StatelessWidget {
  final bool reverse;
  final String title;
  final List<Widget> slivers;

  const _TestCase({
    required this.slivers,
    required this.reverse,
    required this.title,
  });

  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: Column(children: [
        Text(title),
        Expanded(
          child: CustomScrollView(reverse: reverse, slivers: [
            SliverMainAxisGroup(slivers: slivers),
          ]),
        ),
      ]),
    );
  }
}

class _Box extends StatefulWidget {
  final Color color;

  const _Box({
    required this.color,
  });

  @override
  State<_Box> createState() => _BoxState();
}

class _BoxState extends State<_Box> {
  bool _isSelected = false;
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: _toggle,
      child: SizedBox(
        height: 100,
        child: ColoredBox(
          color: _isSelected
              ? Color.lerp(widget.color, Colors.black, .3)!
              : widget.color,
        ),
      ),
    );
  }

  void _toggle() {
    setState(() {
      _isSelected = !_isSelected;
    });
  }
}

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.1, on macOS 14.4 23E214 darwin-arm64, locale en-SI)
    • Flutter version 3.22.1 on channel stable at /Users/.../Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (3 days ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3
@huycozy huycozy added the in triage Presently being triaged by the triage team label May 27, 2024
@huycozy
Copy link
Member

huycozy commented May 27, 2024

I can reproduce this issue on Flutter stable channel but this issue seems to have been fixed on the latest master channel as I cannot reproduce it there.

Demo
Screen.Recording.2024-05-27.at.16.54.51.mov
flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.22.1, on macOS 14.1 23B74 darwin-x64, locale en-VN)
    • Flutter version 3.22.1 on channel stable at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (11 hours ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode15.3.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Applications/Android Studio.app/
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 14.1 23B74 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 125.0.6422.76

[✓] Network resources
    • All expected network resources are available.

• No issues found!
[!] Flutter (Channel master, 3.23.0-8.0.pre.8, on macOS 14.1 23B74 darwin-x64, locale en-VN)
    • Flutter version 3.23.0-8.0.pre.8 on channel master at /Users/huynq/Documents/GitHub/flutter_master
    ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8fd8e66de4 (3 hours ago), 2024-05-26 21:49:30 -0400
    • Engine revision 469193ef0e
    • Dart version 3.5.0 (build 3.5.0-191.0.dev)
    • DevTools version 2.36.0-dev.10
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode15.3.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /Applications/Android Studio.app/
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (3 available)
    • Pixel 7 (mobile) • 2B171FDH20084L • android-arm64  • Android 14 (API 34)
    • macOS (desktop)  • macos          • darwin-x64     • macOS 14.1 23B74 darwin-x64
    • Chrome (web)     • chrome         • web-javascript • Google Chrome 125.0.6422.77

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

I'll close this issue as fixed on the latest channels. If you still experience this issue, kindly leave a comment below and I will reopen this. Thank you!

@huycozy huycozy closed this as completed May 27, 2024
@huycozy huycozy added r: fixed Issue is closed as already fixed in a newer version and removed in triage Presently being triaged by the triage team labels May 27, 2024
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
r: fixed Issue is closed as already fixed in a newer version
Projects
None yet
Development

No branches or pull requests

2 participants