Skip to content

SliverMainAxisGroup does not work as expected when placed in a reverse scroll view #145068

@jellynoone

Description

@jellynoone

Steps to reproduce

  1. Run the example, see a green box rendered at the top
  2. Change home: MainAxisGroupPage(), to home: RegularPage(),
  3. Hot reload
  4. See the green box rendered (correctly), at the bottom.

Expected results

I expect both of these examples to be equivalent i.e. that using a SliverMainAxisGroup or placing all slivers directly in the CustomScrollView would produce the same result. But this doesn't seem to be true.

Actual results

Slivers are rendered on the wrong side of the viewport, when using SliverMainAxisGroup in a reverse scroll view.

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: MainAxisGroupPage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: CustomScrollView(reverse: true, slivers: [
        SliverMainAxisGroup(slivers: [
          SliverToBoxAdapter(
            child: SizedBox(
              height: 100,
              child: ColoredBox(color: Colors.green),
            ),
          ),
          SliverFillRemaining(
            hasScrollBody: false,
            child: ColoredBox(color: Colors.black54),
          ),
        ]),
      ]),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: CustomScrollView(reverse: true, slivers: [
        SliverToBoxAdapter(
          child: SizedBox(
            height: 100,
            child: ColoredBox(color: Colors.green),
          ),
        ),
        SliverFillRemaining(
          hasScrollBody: false,
          child: ColoredBox(color: Colors.black54),
        ),
      ]),
    );
  }
}

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.3, on macOS 14.3.1 23D60 darwin-arm64, locale en-SI)
    • Flutter version 3.19.3 on channel stable at /Users/.../Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ba39319843 (5 days ago), 2024-03-07 15:22:21 -0600
    • Engine revision 2e4ba9c6fb
    • Dart version 3.3.1
    • DevTools version 2.31.1

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

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

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

[✓] Android Studio (version 2023.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 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.88.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.84.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.3.1 23D60 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 122.0.6261.112

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

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: scrollingViewports, list views, slivers, etc.found in release: 3.19Found to occur in 3.19found in release: 3.21Found to occur in 3.21frameworkflutter/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 teamwaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions