Skip to content

SliverMainAxisGroup's childScrollOffset method not overridden #135407

@letsar

Description

@letsar

Is there an existing issue for this?

Steps to reproduce

  1. Run the code below
  2. Taps on the second blue tile

Expected results

The second blue tile should be at the top of the screen

simulator_screenshot_D1FDDB18-3582-4BD9-93B5-57E15CAE2088

Actual results

The first blue tile is at the top of the screen

simulator_screenshot_4EA8BEBA-5B20-4816-933E-8FC207F9D0E3

I think it's because the childScrollOffset method of SliverMainAxisGroup is not overridden, therefore it always returns 0.0.

Code sample

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

void main() {
  runApp(const MaterialApp(home: MyHome()));
}

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

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: CustomScrollView(
        slivers: [
          Tile(color: Colors.green),
          Tile(color: Colors.greenAccent),
          Tile(color: Colors.green),
          Tile(color: Colors.greenAccent),
          Tile(color: Colors.green),
          Tile(color: Colors.greenAccent),
          SliverMainAxisGroup(slivers: [
            Tile(color: Colors.blue),
            Tile(color: Colors.lightBlueAccent),
            Tile(color: Colors.blue),
            Tile(color: Colors.lightBlueAccent),
            Tile(color: Colors.blue),
            Tile(color: Colors.lightBlueAccent),
          ]),
          Tile(color: Colors.yellow),
          Tile(color: Colors.yellowAccent),
          Tile(color: Colors.yellow),
          Tile(color: Colors.yellowAccent),
          Tile(color: Colors.yellow),
          Tile(color: Colors.yellowAccent),
        ],
      ),
    );
  }
}

class Tile extends StatelessWidget {
  const Tile({
    super.key,
    required this.color,
  });

  final Color color;

  @override
  Widget build(BuildContext context) {
    return SliverToBoxAdapter(
      child: GestureDetector(
        onTap: () {
          Scrollable.ensureVisible(context);
        },
        child: SizedBox(
          height: 100,
          child: ColoredBox(
            color: color,
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Logs

Logs

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.13.2, on macOS 12.5.1 21G83 darwin-arm64, locale fr-FR)
    • Flutter version 3.13.2 on channel stable at /Users/xxx/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ff5b5b5fa6 (5 weeks ago), 2023-08-24 08:12:28 -0500
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/xxx/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
    • Xcode at /Applications/Xcode-14.0.0.app/Contents/Developer
    • Build 14A309
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.1)
    • 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
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

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

[✓] Connected device (4 available)
    • IN2023 (mobile)            • 87950fce                             • android-arm64  • Android 13 (API 33)
    • iPhone 13 Pro Max (mobile) • F7BD4E2B-91F5-47DA-9594-0D808C2C260C • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 12.5.1 21G83 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 117.0.5938.92

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: 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 onr: fixedIssue is closed as already fixed in a newer versionteam-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