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

Flutter web Text Widget overflow not working as intended #36043

Closed
icatalud opened this issue Jul 12, 2019 · 12 comments
Closed

Flutter web Text Widget overflow not working as intended #36043

icatalud opened this issue Jul 12, 2019 · 12 comments
Assignees
Labels
a: typography Text rendering, possibly libtxt customer: webeap platform-web Web applications specifically

Comments

@icatalud
Copy link

The Text overflow in flutter web does not work for multiple lines.

For example by placing the following widget in the body of the Scaffold from the initial web project:

Container(
  width: 150,
  child: Text(
    'Hello, World! super length textbox why does it not go beyond 1 lines? It beats me, what is going on, it doesn't work, it's not my fault. But why? why is it? I cannot understand',
    overflow: TextOverflow.ellipsis,
    maxLines: 2,
  ),
),

It does not show the ellipsis (...), however by changing maxLines to 1 it works. By using the exact same code on regular Flutter, it works as intended. It's a Flutter Web issue.

I tried different placements for the Text Widget and in every use case I got the same behavior, maxLines > 1 breaks the overflow logic.

@saravananmnm
Copy link

Can you try this wrap the text

ConstrainedBox(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.5),
child: Wrap(alignment: WrapAlignment.end, children: [
new Text(subTitle ?? null,
textScaleFactor: textSize ?? null,
overflow: TextOverflow.clip,
softWrap: true,
maxLines: 2,
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.black54)),
]),
),

@icatalud
Copy link
Author

Another exception was thrown: TypeError: Instance of 'minified:aZ': type 'minified:aZ' is not a subtype of type 'minified:dv'

It didn't work. In any case, I think Text is not currently working as intended. It should be the same as in Flutter.

@ferhatb ferhatb added the platform-web Web applications specifically label Jul 15, 2019
@yjbanov yjbanov added this to the Near-term Goals milestone Jul 18, 2019
@yjbanov yjbanov added the a: typography Text rendering, possibly libtxt label Jul 18, 2019
@mdebbar
Copy link
Contributor

mdebbar commented Jul 19, 2019

This is a limitation of the current implementation of text rendering.

I'm working on a new implementation that fixes this issue among others. It's still work-in-progress, you can try it by setting this flag to true. Please give it a shot and let us know if that works for you.

@mdebbar mdebbar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 19, 2019
@icatalud
Copy link
Author

That worked, thank you. I hope you get the official Text version working correctly soon.

Steps to get ellipsis working:

  • import 'package:flutter_web_ui/src/engine.dart' show TextMeasurementService;
  • (somewhere in the code) TextMeasurementService.enableExperimentalCanvasImplementation = true;

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 19, 2019
@deckerst
Copy link

@mdebbar is there a way to set this flag when working with the unforked flutter web?

@mdebbar
Copy link
Contributor

mdebbar commented Sep 13, 2019

Unfortunately, after the unfork, there's no easy way to make changes in the web engine (which is where the flag lives). Your best bet currently is to wait until the new implementation is ready and isn't experimental anymore. I'll be spending some time on it in the coming weeks, but I don't have an exact date for when it'll be done.

@ymback
Copy link

ymback commented Sep 19, 2019

Any news?

@McLarenCollege
Copy link

@mdebbar I'm really looking forward to this fix :) if it's not likely to be fixed soon, it would be great if you could temporarily expose the enableExperimentalCanvasImplementation flag in the web engine

@deckerst
Copy link

Freshly available (haven't tried yet):
flutter run -d web-server --release --dart-define=FLUTTER_WEB_USE_EXPERIMENTAL_CANVAS_TEXT=true

@mdebbar
Copy link
Contributor

mdebbar commented Nov 23, 2019

Thanks @deckerst 😄

@McLarenCollege try the command that @deckerst suggested. It was added in flutter/engine#13929 that was merged yesterday. Please file issues if you encounter any, and make sure to mention in your issue that you are using this flag :)

@mdebbar mdebbar closed this as completed Nov 23, 2019
@McLarenCollege
Copy link

Yay it's working now! thank you for such a fast response

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: typography Text rendering, possibly libtxt customer: webeap platform-web Web applications specifically
Projects
None yet
Development

No branches or pull requests

9 participants