Skip to content

support shrinkToFit property in 1.0.0 #297

@Digoun

Description

@Digoun

It seems the property shrinkToFit from the old RichText parser is not supported anymore in latest version 1.0.0, but it wasn't mentioned in the migration guide.
I'm still quite new user of this library, what is the best way to avoid having the Html widget using a double.infinity width ?

Maybe would it make sense to add back support for this property shrinkToFit in the SizeBox to avoid having double.infinity?

Something in that mind maybe:

class StyledText extends StatelessWidget {
  final InlineSpan textSpan;
  final Style style;
  final bool shrinkToFit;

  const StyledText({
    this.textSpan,
    this.style,
    this.shrinkToFit = false
  });

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: (style.display == Display.BLOCK || style.display == Display.LIST_ITEM) && !this.shrinkToFit
          ? double.infinity
          : null,
      child: Text.rich(
        textSpan,
        style: style.generateTextStyle(),
        textAlign: style.textAlign,
        textDirection: style.direction,
      ),
    );
  }
}

Thanks in advance for your suggestions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions