auto_size_text icon indicating copy to clipboard operation
auto_size_text copied to clipboard

Does not work with Flutter Web --web-renderer = html (default for mobile)

Open MyBuzzTechnologies opened this issue 4 years ago • 18 comments

Create a simple app with AutoSizeText:

Widget build(BuildContext context) { return Container( // color: Colors.red, // child: const Center(child: Text("Reports")), child: Center( child: Container( width: 60, decoration: BoxDecoration(border: Border.all()), child: const AutoSizeText("Sample long text", minFontSize: 5, maxLines: 1), ))); }

Run with:

flutter -d chrome --web-renderer html

image

Note: the text does not resize correctly. If you run with --web-renderer canvasKit (the default for desktop) the text resizes correctly.

image

Flutter (Channel beta, 1.26.0-17.3.pre, on macOS 11.2.1 20D74 darwin-arm, locale en-GB) • Flutter version 1.26.0-17.3.pre • Framework revision 4b50ca7f7f (11 days ago) • Engine revision 2c527d6c7e • Dart version 2.12.0 (build 2.12.0-259.8.beta)

auto_size_text: ^2.1.0 (also tried 3.0.0-nullsafety.0 - same problem)

Reproducible on Chrome version 88.0.4324.150 (Official Build) (x86_64 translated)

Also has same problem on iPhone Safari browser (iOS 14.3)

MyBuzzTechnologies avatar Feb 16 '21 09:02 MyBuzzTechnologies

I have this exact issue as well.

ghunkins avatar Feb 16 '21 22:02 ghunkins

please stable version.. after the flutter event

Xim-ya avatar Feb 18 '21 08:02 Xim-ya

Same problem.

MiroLiebschner avatar Mar 05 '21 09:03 MiroLiebschner

This is caused by https://github.com/flutter/flutter/issues/65940. auto_size_text checks TextPainter.didExceedMaxLines to determine the right font size, but it's always returning false. The package is given the impression that the text always fits.

doppio avatar Apr 01 '21 03:04 doppio

Could this be the reason that debugging in desktop chrome and changing to a smartphone aspect ratio resizes the text, but on a smartphone itself it doesn't?

Is there any workaround for this?

skiunke avatar Aug 15 '21 16:08 skiunke

I'm facing the same issue, on desktop is all fine but when I compile and run on the smartphone it doesn't work

leonardopivetta avatar Aug 19 '21 10:08 leonardopivetta

I have this exact issue as well.

smok95 avatar Nov 02 '21 23:11 smok95

Same here.

P-B1101 avatar Dec 13 '21 23:12 P-B1101

same here

kipouras avatar Jan 04 '22 09:01 kipouras

A little hack if you have to deploy your web app (not a fix):

  • add this right after your

    tag in your web/index.html: <script> window.flutterWebRenderer = 'canvaskit'; </script>
  • build using flutter build web --web-renderer auto

It will force the web renderer to 'canvaskit'.

JorisObert avatar Jan 27 '22 21:01 JorisObert

A little hack if you have to deploy your web app (not a fix):

  • add this right after your tag in your web/index.html: <script> window.flutterWebRenderer = 'canvaskit'; </script>
  • build using flutter build web --web-renderer auto

It will force the web renderer to 'canvaskit'.

You can actually just flutter build web --web-renderer canvaskit. No need to modify your HTML.

doppio avatar Jan 27 '22 22:01 doppio

@doppio I had to launch a little website on Firebase Hosting and doing just flutter build web --web-renderer canvaskit did not work for me.

JorisObert avatar Jan 28 '22 11:01 JorisObert

still same. In Flutter Web doesnt work properly

guccisekspir avatar Feb 28 '22 09:02 guccisekspir

There's nothing the author of this package can do until https://github.com/flutter/flutter/issues/65940 is resolved, please thumbs-up that issue instead of "same here" comments so it gets prioritized by the Flutter team. 🙂

doppio avatar Feb 28 '22 19:02 doppio

hello everyone, run: flutter build web --release --web-renderer html => auto_size_text not working. but, if run: flutter build web --release => working for me

ligker2 avatar Mar 12 '22 05:03 ligker2

It seems to be fixed in flutter 2.10.3! I've tried running my app on WEB using --web-renderer html and auto_size_text works as expected. Might need a little more testing, but I think we can close this issue now.

Just installed 2.10.4, doesn't seem to work with the html renderer for me.

MorelSerge avatar Mar 30 '22 17:03 MorelSerge

It seems to be fixed in flutter 2.10.3! I've tried running my app on WEB using --web-renderer html and auto_size_text works as expected. Might need a little more testing, but I think we can close this issue now.

Just installed 2.10.4, doesn't seem to work with the html renderer for me.

Sorry I am using --web-renderer canvaskit. I don't know what happened to me that day

SeriousMonk avatar Mar 30 '22 18:03 SeriousMonk

Any update on this? The problem is still there...

remantou avatar Dec 21 '22 10:12 remantou