Skip to content

CarouselView.weighted throws when given zero constraints #167621

Closed

Description

@bleroux

Steps to reproduce

  1. Run the code sample (debug or release mode. Without the zeroed SizedBox the issue is reproducible in release mode on Android).
  2. Observe the error log.

Expected results

No exception thrown.

Actual results

Several exceptions in the error log.

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 const MaterialApp(
      home: Scaffold(
        // The issue is also reproducible without a zero width SixedBox.
        // In release mode, especially on Android, the initial viewport dimension
        // is usually zero.
        body: SizedBox(
          width: 0,
          child: CarouselView.weighted(
            flexWeights: <int>[1, 2],
            children: <Widget>[FlutterLogo(), FlutterLogo()],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Logs

Logs
════════ Exception caught by rendering library ═════════════════════════════════
The following UnsupportedError was thrown during performLayout():
Unsupported operation: Infinity or NaN toInt

The relevant error-causing widget was:
    CarouselView CarouselView:file:///Users/bruno/Nevercode/investigationapp/lib/0%20-%20Investigate/Various/flutter_105630/flutter_105630_carousel_flutter_logo.dart:14:31

When the exception was thrown, this was the stack:
#0      double.toInt (dart:core-patch/double.dart)
#1      double.round (dart:core-patch/double.dart:196:34)
double.dart:196
#2      _RenderSliverWeightedCarousel._firstVisibleItemIndex (package:flutter/src/material/carousel.dart:918:69)
carousel.dart:918
#3      _RenderSliverWeightedCarousel.getMinChildIndexForScrollOffset (package:flutter/src/material/carousel.dart:981:21)
carousel.dart:981

Flutter Doctor output

Doctor output
[!] Flutter (Channel master, 3.32.0-1.0.pre.200, on macOS 14.2.1 23C71 darwin-arm64, locale fr-FR)
    ! Upstream repository [email protected]:bleroux/flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to [email protected]:bleroux/flutter.git to dismiss
      this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.1)
    ! CocoaPods 1.11.3 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see
      https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.99.3)
[✓] Connected device (2 available)
[✓] Network resources

Activity

  1. added
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    a: error messageError messages from the Flutter framework
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    P2Important issues not at the top of the work list
    team-designOwned by Design Languages team
    triaged-designTriaged by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Apr 23, 2025
  2. self-assigned this
    on Apr 23, 2025
  3. moved this from To do to PR submitted in Nevercodeon Apr 27, 2025
  4. moved this from PR submitted to Done (PR merged) in Nevercodeon Apr 28, 2025
  5. added
    r: fixedIssue is closed as already fixed in a newer version
    on Apr 28, 2025
  6. github-actions commented on May 12, 2025

    @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 May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkfound in release: 3.29Found to occur in 3.29found in release: 3.32Found to occur in 3.32frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

  • Status
    Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions