Skip to content

CarouselView.weighted throws SliverGeometry exception: maxPaintExtent is less than paintExtent #188380

Closed
flutter/packages
#12563

Description

@Mairramer

Steps to reproduce

  1. Create an application using CarouselView.weighted with infinite: false (which is the default).
  2. Configure it with an asymmetric flexWeights array that ends with a large base weight (e.g. [1, 7]).
  3. Provide a small finite number of children (e.g. 5 items).
  4. Run the app and manually scroll/fling all the way to the end of the carousel.

Expected results

The CarouselView should scroll smoothly and gracefully stop at the boundary of the last item without throwing any rendering exceptions.

Actual results

The app does not crash entirely, but during the scroll/drag interaction it throws a SliverGeometry is not valid rendering exception in the logs, complaining that maxPaintExtent is less than paintExtent. Because the layout calculation is aborted, the scroll behavior becomes erratic, fighting the user or snapping weirdly.

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(
      home: Scaffold(
        appBar: AppBar(title: const Text('Carousel Bug Repro')),
        body: Column(
          children: [
            Expanded(
              child: CarouselView.weighted(
                flexWeights: const [1, 7],
                children: List<Widget>.generate(
                  5,
                  (int index) => Container(
                    color: Colors.primaries[index % Colors.primaries.length],
                    child: Center(child: Text('Item $index', style: const TextStyle(fontSize: 24))),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
SliverGeometry is not valid: The "maxPaintExtent" is less than the "paintExtent".
The maxPaintExtent is 606.0, but the paintExtent is 663.5.
By definition, a sliver can't paint more than the maximum that it can paint!
The RenderSliver that returned the offending geometry was: _RenderSliverWeightedCarousel#aae74 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
  needs compositing
  creator: _SliverWeightedCarousel ← Viewport ← IgnorePointer-[GlobalKey#941a7] ← Semantics ← Listener
    ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#f66a1] ←
    Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#e2e33] ←
    NotificationListener<ScrollMetricsNotification> ← Transform ← ⋯
  parentData: paintOffset=Offset(0.0, 0.0) (can use size)
  constraints: SliverConstraints(AxisDirection.right, GrowthDirection.forward, ScrollDirection.idle,
    scrollOffset: 461.5, precedingScrollExtent: 0.0, remainingPaintExtent: 750.0, crossAxisExtent:
    1000.0, crossAxisDirection: AxisDirection.down, viewportMainAxisExtent: 750.0,
    remainingCacheExtent: 750.0, cacheOrigin: -0.0)
  geometry: SliverGeometry(scrollExtent: 606.0, paintExtent: 663.5, maxPaintExtent: 606.0,
    hasVisualOverflow: true, cacheExtent: 663.5)
  currently live children: 3 to 4

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.44.0, on macOS 26.5.1 25F80 darwin-arm64, locale
    pt-BR) [673ms]
    • Flutter version 3.44.0 on channel stable at
      /Users/mairramersilva/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 559ffa3f75 (6 weeks ago), 2026-05-15 14:13:13 -0700
    • Engine revision 4c525dac5e
    • Dart version 3.12.0
    • DevTools version 2.57.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop,
      enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-native-assets, enable-swift-package-manager,
      omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[!] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
    [2,1s]
    • Android SDK at /Users/mairramersilva/Library/Android/sdk
    • Emulator version 36.3.10.0 (build_id 14472402) (CL:N/A)
    • Platform android-36, build-tools 36.1.0
    • ANDROID_HOME = /Users/mairramersilva/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/mairramersilva/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.7+-13880790-b1038.58)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor
      --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 26.0) [2,1s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17A324
    • 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,3s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 26.5.1 25F80 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 149.0.7827.116

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

! Doctor found issues in 1 category.

Activity

  1. added
    c: crashStack traces logged to the console
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    on Jun 23, 2026
  2. mbcorona commented on Jun 23, 2026

    @mbcorona
    Member

    Hi @Mairramer , thanks for the detailed report and linked pr, routing to the design team for evaluation.

  3. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Jun 24, 2026
  4. dkwingsmt commented on Jun 24, 2026

    @dkwingsmt
    Contributor
  5. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
  6. github-actions commented on Sep 21, 2026

    @github-actions

    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.

  7. locked as resolved and limited conversation to collaborators on Sep 21, 2026
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

    P2Important issues not at the top of the work listc: crashStack traces logged to the consolefound in release: 3.44Found to occur in 3.44has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions