flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

Support for the `text-indent` CSS Attributes

Open FlafyDev opened this issue 2 years ago • 8 comments

Describe your feature request

Support for the text-indent CSS Attribute. mdn for explanation and examples on the attribute

A picture of a cute animal (not mandatory but encouraged)

Debian cat

FlafyDev avatar May 05 '22 13:05 FlafyDev

text-indent natively in Flutter can be done like so:

TextSpan(
  children: [
    WidgetSpan(child: SizedBox(width: 40.0)),
    TextSpan(text: 'lorem impsum...'),
  ],
)

From https://stackoverflow.com/questions/68260166/is-there-a-way-to-indent-just-the-first-line-of-wrapped-text-in-flutter

FlafyDev avatar May 05 '22 14:05 FlafyDev

text-indent natively in Flutter can be done like so:

TextSpan(
  children: [
    WidgetSpan(child: SizedBox(width: 40.0)),
    TextSpan(text: 'lorem impsum...'),
  ],
)

From https://stackoverflow.com/questions/68260166/is-there-a-way-to-indent-just-the-first-line-of-wrapped-text-in-flutter

How would I do this in customRender and return the parsedChild instead of the text? I tried this code but the indent just gets ignored. Using context.tree.element?.text is not an option because then it ignores other styling

(Note, the element?.styles is an extension from flutter_widget_from_html)

'p': (context, parsedChild) {
  if (context.tree.element?.styles
          .map((style) => style.property)
          .contains('text-indent') ??
      false) {
    // final style = context.tree.element?.styles
    //     .where((style) => style.property == 'text-indent')
    //     .first;
    // print(style?.value?.span);
    return TextSpan(
      children: [
        const WidgetSpan(child: SizedBox(width: 40.0)),
        WidgetSpan(child: parsedChild),
      ],
    );
  }
}

getBoolean avatar May 09 '22 01:05 getBoolean

Same question, is there a solution?

Etermally avatar May 13 '22 06:05 Etermally

I added limited support for the css attribute in my fork of this repo, you can look at it if you want

FlafyDev avatar May 13 '22 08:05 FlafyDev

I think we can do based support (with a fixed value) fairly easily, but the percentage-bases support will already be tricky to implement in Flutter.

erickok avatar May 19 '22 09:05 erickok

Please support this property!

gopalkriagg avatar Dec 19 '22 03:12 gopalkriagg

With the new Width class, I think this has become more feasible. I'll look into getting this added

Sub6Resources avatar May 09 '23 18:05 Sub6Resources

Please, implement support of this property! It is very needed! 🙏♥️🦔

atkach1 avatar Jul 05 '23 11:07 atkach1