flutter_html
flutter_html copied to clipboard
Support for the `text-indent` CSS Attributes
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
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
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),
],
);
}
}
Same question, is there a solution?
I added limited support for the css attribute in my fork of this repo, you can look at it if you want
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.
Please support this property!
With the new Width
class, I think this has become more feasible. I'll look into getting this added
Please, implement support of this property! It is very needed! 🙏♥️🦔