Skip to content

When adding in-line WidgetSpans, Richtext width is measured incorrectly #62551

@mehmetf

Description

@mehmetf

Repro:

Container(
    padding: EdgeInsets.all(matGrid * 2),
    child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text('LTR Text and Widget Spans (Default TextWidthBasis):',
              style: Theme.of(context).textTheme.caption),
          Container(
              decoration: BoxDecoration(border: Border.all(width: 1)),
              child: Text.rich(TextSpan(children: [
                TextSpan(text: 'this is a line of text with words---'),
                WidgetSpan(
                    child: SizedBox(
                        width: 20,
                        height: 20,
                        child: Container(color: Colors.green)))
              ]))),
          Container(
              decoration: BoxDecoration(border: Border.all(width: 1)),
              child: Text.rich(TextSpan(children: [
                TextSpan(
                    text:
                        'this is a line of text with words followed by areallylongwordthatneedstobewrapped---'),
                WidgetSpan(
                    child: SizedBox(
                        width: 20,
                        height: 20,
                        child: Container(color: Colors.green)))
              ]))),
          Text(
              'LTR Text and Widget Spans (TextWidthBasis.longestLine):',
              style: Theme.of(context).textTheme.caption),
          Container(
              decoration: BoxDecoration(border: Border.all(width: 1)),
              child: Text.rich(
                  TextSpan(children: [
                    TextSpan(
                        text: 'this is a line of text with words---'),
                    WidgetSpan(
                        child: SizedBox(
                            width: 20,
                            height: 20,
                            child: Container(color: Colors.green)))
                  ]),
                  textWidthBasis: TextWidthBasis.longestLine)),
          Container(
              decoration: BoxDecoration(border: Border.all(width: 1)),
              child: Text.rich(
                  TextSpan(children: [
                    TextSpan(
                        text:
                            'this is a line of text with words followed by areallylongwordthatneedstobewrapped---'),
                    WidgetSpan(
                        child: SizedBox(
                            width: 20,
                            height: 20,
                            child: Container(color: Colors.green)))
                  ]),
                  textWidthBasis: TextWidthBasis.longestLine))
        ]));

produces the following output (only relevant widgets are the ones with green boxes. The customer reported two separate issues with the same screenshot. The other one is filed here: #62550.

image

Metadata

Metadata

Labels

P1High-priority issues at the top of the work lista: typographyText rendering, possibly libtxtcustomer: mulligan (g3)frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions