Skip to content

Wrapped Text has unexpected intrinsic size #27293

@sma

Description

@sma

I'd expect wrapped Text to have an intrinsic size that fits the text. However, if I wrap such a text with an IntrinsicHeight widget, the height includes the first line, only. If wrapped with an IntrinsicWidth widget, on the other hand, the width does not only fit the text, but stretches to the available width.

Here is an example for "intrinsic height only includes the first line" (the yellow box should include all three lines):

image

class TestPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: IntrinsicHeight(
          child: Container(
            color: Colors.black12,
            width: 105,
            alignment: Alignment.centerLeft,
            child: IntrinsicWidth(
              child: Container(
                color: Colors.yellow,
                child: Text("Hallo! dies sollte umbrechen"),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Here is an example for "intrinsic width stretches to available width" (the yellow box should be left-aligned and stop at the "n" in the third line):

image

class TestPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Container(
          color: Colors.back12,
          width: 105,
          height: 105,
          alignment: Alignment.centerLeft,
          child: IntrinsicWidth(
            child: Container(
              color: Colors.yellow,
              child: Text("Hallo! dies sollte umbrechen"),
            ),
          ),
        ),
      ),
    );
  }
}

My Flutter version:

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.1.10-pre.220, on Mac OS X 10.14.2 18C54, locale de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.3)
[✓] VS Code (version 1.30.2)
[✓] Connected device (1 available)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: typographyText rendering, possibly libtxtfound in release: 3.7Found to occur in 3.7found in release: 3.8Found to occur in 3.8frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions