Skip to content

Conversation

@justinmc
Copy link
Contributor

@justinmc justinmc commented Apr 12, 2019

Closes #26585, #15300
Depends on flutter/engine#8530

Paragraph currently sets its width to be the maximum space allowed for it when it wraps beyond one line. This creates extra empty space when you want to draw something with a tight container:

51184156-82592080-18e4-11e9-8906-2bbce4f6327f

This PR will enable the drawing of a paragraph with a width only as wide as it needs to be to contain wrapping text tightly.

@justinmc justinmc changed the title WIP Tight Paragraph Width Tight Paragraph Width Apr 15, 2019
@justinmc
Copy link
Contributor Author

This will have to wait for the corresponding engine PR to go in before its tests can pass (flutter/engine#8530).

@justinmc justinmc requested review from GaryQian and HansMuller April 15, 2019 18:28
@Hixie Hixie added the framework flutter/packages/flutter repository. See also f: labels. label Apr 16, 2019
@HansMuller
Copy link
Contributor

It might be best to change the naming for the sake of consistency. Stacks have a fit parameter whose value is StackFit (enum). Since this feature is for Text: maybe Text.fit and TextFit, where TextFit is either expand or tight.

@GaryQian
Copy link
Contributor

I do think that the word Width should probably be in there somewhere as this specifically deals with the width of the paragraph.

@HansMuller
Copy link
Contributor

@GaryQian How about TextFitWidth and Text.fitWidth?

@GaryQian
Copy link
Contributor

GaryQian commented Apr 19, 2019

Maybe TextWidthFit sounds a bit more natural? I'm not totally convinced on the Fit part either, as it looks like the StackFit is dealing with constraints directly whereas this is just a simple switch for which metric to use.

@sroddy
Copy link
Contributor

sroddy commented Apr 22, 2019

is this related/the same issue? #15300

@GaryQian
Copy link
Contributor

GaryQian commented Apr 22, 2019

Yes, #15300 seems to be the same issue. Adding to the desc.

Hixie called it "longestLine" which also seems to make sense...

@HansMuller
Copy link
Contributor

OK, I propose that we call the enum TextWidthBasis (because it's what the text widget's width is based on), with values parent and longestLine, and we call the parameter textWidthBasis.

@justinmc
Copy link
Contributor Author

This is ready for a final review.

// The current behavior, unchanged.
// A short single line is wrapped tightly.
// Multiple lines cause the text to take the full width of its parent.
Text(
  string,
  textWidthBasis: TextWidthBasis.parent, //default
)
// For a single line, the behavior is the same! Tightly wrapped.
// For multiple lines, the width is only the width of the longest line.
Text(
  string,
  textWidthBasis: TextWidthBasis.longestLine,
)

Green is parent and pink is longestLine:

@justinmc
Copy link
Contributor Author

The tests are failing because they think longestLine doesn't exist in the engine, but the engine was rolled into flutter/flutter with my change here: 3cd15b5

Do I need to wait for something else?

@GaryQian
Copy link
Contributor

GaryQian commented Apr 29, 2019

Sometimes the luci engine buildbots haven't caught up yet, i'd check https://ci.chromium.org/p/flutter/builders/luci.flutter.prod/Linux%20Host%20Engine
and here for all the builders: https://ci.chromium.org/p/flutter/builders

Although it does look like everything is caught up.

It is also strange that everything else worked, but those specific ones failed as if the engine build was bad, many of the other tests should have failed too

@justinmc
Copy link
Contributor Author

justinmc commented May 2, 2019

@dnfield After merging in your addition of flutter doctor, the same tests are still failing. If I look at the output of the failure, I don't think I see flutter doctor being run, but maybe I'm looking for the wrong thing. Shouldn't I find something with ctrl-f "doctor" in the failing test output?

@dnfield
Copy link
Contributor

dnfield commented May 2, 2019

It looks like it ran from the output. Are we sure 6280d42 is the right engine hash?

@justinmc
Copy link
Contributor Author

justinmc commented May 2, 2019

Yeah that hash should be fine. The engine commit I need is flutter/engine@3493dcf, which looks to be about 5 days older than 6280d42.

@justinmc
Copy link
Contributor Author

justinmc commented May 2, 2019

I'm going to go ahead and merge this and see what happens. If anything fails then I'll immediately revert.

@dnfield
Copy link
Contributor

dnfield commented May 2, 2019

SGTM.

@justinmc justinmc merged commit 323108f into flutter:master May 2, 2019
@justinmc justinmc deleted the text-wrap-width branch May 2, 2019 16:21
justinmc added a commit that referenced this pull request May 2, 2019
justinmc added a commit that referenced this pull request May 2, 2019
This reverts commit 323108f due to weird engine dependency bug
@justinmc justinmc mentioned this pull request May 2, 2019
@justinmc justinmc restored the text-wrap-width branch May 2, 2019 18:21
@justinmc justinmc mentioned this pull request May 2, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text widget doesn't change it's size when line break happened

7 participants