Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoSizeGroup doesn't work on web/Android #126

Open
MarcVanDaele90 opened this issue Oct 26, 2022 · 3 comments
Open

AutoSizeGroup doesn't work on web/Android #126

MarcVanDaele90 opened this issue Oct 26, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@MarcVanDaele90
Copy link

Steps to Reproduce

  • create a project with the code below
  • build it using flutter build web
  • put the build/web directory on a webserver
  • access this url from both chrome/Linux (works fine) and from chrome/Android (does not work)

The code below runs fine

  • on web(chrome)/Linux
  • on Android (as app)
  • but NOT on web(chrome)/Android
    In the later case, the autosizing does not seem to work.

Code sample

      body: Row(
        children:[
          Spacer(flex:3),
          Expanded(child: Card(child: AutoSizeText("aaa", group: autoSizeGroup, maxLines:1, minFontSize: 6, style: textStyle))),
          Expanded(child: Card(child: AutoSizeText("somewhat longer", group: autoSizeGroup, maxLines: 1, minFontSize: 6, style: textStyle))),
          Spacer(flex:3)
        ]
      ),

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot added from linux chrome browser and Android chrome browser. Same problem is observed on iOS/Chrome+safari
image
Screenshot_20221026-164845_Chrome

Version

  • auto_size_text version: 3.0.0
  • Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.3.5, on Linux Mint 20.2 5.15.0-46-generic, locale
    en_US.UTF-8)
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    [✓] Chrome - develop for the web
    [✓] Linux toolchain - develop for Linux desktop
    [✓] Android Studio (version 2022.1)
    [✓] VS Code (version 1.70.1)
    [✓] Connected device (2 available)
    [✓] HTTP Host Availability
@MarcVanDaele90 MarcVanDaele90 added the bug Something isn't working label Oct 26, 2022
@MarcVanDaele90
Copy link
Author

This is apparently triggered by flutter/flutter#65940

@MarcVanDaele90
Copy link
Author

I have a temporary workaround (which is inefficient and probably incomplete but it might be helpful to others).

I replaced textpainter.didExceedMaxLines with

    final textPainter2 = TextPainter(
      text: text,
      textAlign: widget.textAlign ?? TextAlign.left,
      textDirection: widget.textDirection ?? TextDirection.ltr,
      textScaleFactor: scale,
      maxLines: maxLines==null?maxLines:maxLines+1,
      locale: widget.locale,
      strutStyle: widget.strutStyle,
    );
    textPainter2.layout(maxWidth: constraints.maxWidth);

    bool didExceedMaxLines = textPainter2.height>textPainter.height;

This fixes the issue on my side (note that I didn't touch wordWrapTextPainter because I didn't need this right now)

@maRci002
Copy link

It seems flutter/engine#34085 PR did fix the issue it is available in Flutter 3.7.0 stable release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants