Closed clragon closed 2 years ago
Thanks @clragon
I will surely work on it as it seems a very nice way to make people not import dart:html
in their code.
If you want to work on it and raise a PR let me know, otherwise I'll take it probably this weekend.
It would be nice if Header elements could be specified for
TextRenderer
without having to importdart:html
. This would allow making sure certain things are rendered as Headers when needed without making the code dependent on web.One approach for doing this would be to replace the
element
parameter onTextRenderer
with an Enum like this:enum
```dart enum HtmlTextType { paragraph, header1, header2, header3, header4, header5, header6, } ```Both the web text renderer and the vm text renderer could accept this parameter and handle it differently: by converting it into a Html Heading element on web and ignoring it on VM.
type conversion
```dart HtmlElement typeToElement(HtmlTextType? type) { switch (type) { case HtmlTextType.header1: return HeadingElement.h1(); case HtmlTextType.header2: return HeadingElement.h2(); case HtmlTextType.header3: return HeadingElement.h3(); case HtmlTextType.header4: return HeadingElement.h4(); case HtmlTextType.header5: return HeadingElement.h5(); case HtmlTextType.header6: return HeadingElement.h6(); case HtmlTextType.paragraph: default: return ParagraphElement(); } } ```