toWidget method
Implementation
@override
Widget toWidget(RenderContext context) {
String? textNode;
List<Widget> widgets = <Widget>[];
final rubySize = max(9.0, context.style.fontSize!.size! / 2);
final rubyYPos = rubySize + rubySize / 2;
context.tree.children.forEach((c) {
if (c is TextContentElement) {
textNode = c.text;
}
if (!(c is TextContentElement)) {
if (c.name == "rt" && textNode != null) {
final widget = Stack(
alignment: Alignment.center,
children: <Widget>[
Container(
alignment: Alignment.bottomCenter,
child: Center(
child: Transform(
transform:
Matrix4.translationValues(0, -(rubyYPos), 0),
child: ContainerSpan(
newContext: RenderContext(
buildContext: context.buildContext,
parser: context.parser,
style: c.style,
tree: c,
),
style: c.style,
child: Text(c.element!.innerHtml,
style: c.style
.generateTextStyle()
.copyWith(fontSize: rubySize)),
)))),
ContainerSpan(
newContext: context,
style: context.style,
child: Text(textNode!.trim(),
style: context.style.generateTextStyle())),
],
);
widgets.add(widget);
}
}
});
return Row(
key: AnchorKey.of(context.parser.key, this),
crossAxisAlignment: CrossAxisAlignment.end,
textBaseline: TextBaseline.alphabetic,
mainAxisSize: MainAxisSize.min,
children: widgets,
);
}