Skip to content

AutoSizeText throws "Infinity or NaN toInt" error in release mode #151

@Yograj1410

Description

@Yograj1410

When using AutoSizeText in a ListView with dynamic content loading, the app crashes in release mode with the following error:

Unsupported operation: Infinity or NaN toInt
#0 State.widget (package:flutter/src/widgets/framework.dart)
#1 _AutoSizeTextState._calculateFontSize (package:auto_size_text/src/auto_size_text.dart:332)

Steps to reproduce:

  1. Create an AutoSizeText widget in a ListView
  2. Load dynamic content
  3. Run app in release mode
  4. Scroll through the list faster

Current behavior:
App crashes with "Infinity or NaN toInt" error

Expected behavior:
Text should resize properly without crashing

Flutter doctor result (flutter doctor -v ):
[✓] Flutter (Channel stable, 3.22.0, on macOS 14.4.1 23E224 darwin-arm64, locale
en-US)
• Flutter version 3.22.0 on channel stable at
/Users/apple/fvm/versions/3.22.0
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5dcb86f68f (10 months ago), 2024-05-09 07:39:20 -0500
• Engine revision f6344b75dc
• Dart version 3.4.0
• DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
• Android SDK at /Users/apple/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.

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

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

[✓] Android Studio (version 2023.3)
• 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.10+0-17.0.10b1087.21-11572160)

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

[✓] Connected device (4 available)
• SM S711B (mobile) • RZCX91X9Y9D • android-arm64 •
Android 14 (API 34)
• macOS (desktop) • macos • darwin-arm64 •
macOS 14.4.1 23E224 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin •
macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript •
Google Chrome 133.0.6943.127

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

• No issues found!

Additional context:

  • Occurs only in release mode
  • Works fine in debug mode
  • Using auto_size_text: 3.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions