simc / auto_size_text

Flutter widget that automatically resizes text to fit perfectly within its bounds.
https://pub.dev/packages/auto_size_text
MIT License
2.06k stars 240 forks source link

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

Open MyBuzzTechnologies opened 3 years ago

MyBuzzTechnologies commented 3 years ago

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)

ghunkins commented 3 years ago

I have this exact issue as well.

Xim-ya commented 3 years ago

please stable version.. after the flutter event

MiroLiebschner commented 3 years ago

Same problem.

doppio commented 3 years ago

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.

skiunke commented 3 years ago

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?

leonardopivetta commented 3 years ago

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

smok95 commented 3 years ago

I have this exact issue as well.

P-B1101 commented 2 years ago

Same here.

kipouras commented 2 years ago

same here

JorisObert commented 2 years ago

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

It will force the web renderer to 'canvaskit'.

doppio commented 2 years ago

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.

JorisObert commented 2 years ago

@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.

guccisekspir commented 2 years ago

still same. In Flutter Web doesnt work properly

doppio commented 2 years ago

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. 🙂

ligker2 commented 2 years ago

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

MorelSerge commented 2 years ago

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.

SeriousMonk commented 2 years ago

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

remantou commented 1 year ago

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