Skip to content

TextWidthBasis.longestLine prevents text from unwrapping when width constraints increase #142309

@letsar

Description

@letsar

Steps to reproduce

This bug already exists here, but it has been closed

Use case

When using textWidthBasis: TextWidthBasis.longestLine in a Text widget, if we decrease the size of the window (web or desktop), the text shrinks correctly, but when we increase the size of the window again, the text does not expand.
This does not happen with TextWidthBasis.parent.
See the attached video.

Expected results

The text is correctly resized when the size of the window increases

Actual results

The text is not resized when the size of the window increases

Code sample

Code sample
void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: _Home(),
    );
  }
}

class _Home extends StatelessWidget {
  const _Home();

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Center(
        child: Text(
          'My very very very long text which is not resized properly when the window is resized',
          overflow: TextOverflow.ellipsis,
          maxLines: 1,
          textWidthBasis: TextWidthBasis.longestLine,
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
text-width-basis-issue-longest-line_rvgtfnEj.mp4

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.16.9, on macOS 14.1.1 23B81 darwin-arm64, locale fr-FR)
    • Flutter version 3.16.9 on channel stable at /Users/xxxxxxx/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 41456452f2 (23 hours ago), 2024-01-25 10:06:23 -0800
    • Engine revision f40e976bed
    • Dart version 3.2.6
    • DevTools version 2.28.5

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/xxxxxxx/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.0.1)
    • Xcode at /Applications/Xcode-15.0.1.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.14.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.85.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.80.0

[✓] Connected device (3 available)
    • IN2023 (mobile) • 87950fce • android-arm64  • Android 13 (API 33)
    • macOS (desktop) • macos    • darwin-arm64   • macOS 14.1.1 23B81 darwin-arm64
    • Chrome (web)    • chrome   • web-javascript • Google Chrome 120.0.6099.234

[✓] 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 lista: typographyText rendering, possibly libtxtfound in release: 3.16Found to occur in 3.16found in release: 3.19Found to occur in 3.19frameworkflutter/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