flutter_html
flutter_html copied to clipboard
[QUESTION] Migrate to version 3
Hey I can't find anything about migrating to version 3 from 2 I wish to change my custom rendered tags to the new format. Here is an example:
'blockquote': (code, child) {
return Container(
decoration: const BoxDecoration(
border: Border(
left: BorderSide(
color: Color.fromRGBO(0x99, 0xc9, 0xff, 1), width: 2),
),
),
child: child,
);
}
I have the same problem.
I ended up doing it like this @moNiti
blockQuoteMatcher(): CustomRender.widget(widget: (code, child) {
return Container(
decoration: const BoxDecoration(
border: Border(
left: BorderSide(
color: Color.fromRGBO(0x99, 0xc9, 0xff, 1), width: 2),
decoration: const BoxDecoration(
border: Border(
left: BorderSide(
color: Color.fromRGBO(0x99, 0xc9, 0xff, 1), width: 2),
),
),
),
child: child,
);
}
CustomRenderMatcher blockQuoteMatcher() =>
(context) => context.tree.element?.localName == 'blockquote';
But the child in parameter is not widget type
The argument type 'List<InlineSpan> Function()' can't be assigned to the parameter type 'Widget?
flutter_html: 3.0.0-alpha.5
Yes, I forgot to add that in my example:
- add a Row widget
- Make a for-loop that checks for the number of new lines:
for (var line in code.tree.element!.text.split('\n'))
- Put your
line
in an expanded and a Text widget
You can set the style of the text like font-size: textStyle: TextStyle(fontSize: code.style.fontSize!.size)
Migration guide has been added at https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#300