Skip to content

Commit 8bdb767

Browse files
committed
Fix analysis hints in flutter_html_math
1 parent a346914 commit 8bdb767

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

packages/flutter_html_math/lib/flutter_html_math.dart

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CustomRender mathRender({OnMathError? onMathError}) =>
1313
String texStr = context.tree.element == null
1414
? ''
1515
: _parseMathRecursive(context.tree.element!, r'');
16-
return Container(
16+
return SizedBox(
1717
width: context.parser.shrinkWrap
1818
? null
1919
: MediaQuery.of(context.buildContext).size.width,
@@ -40,9 +40,9 @@ String _parseMathRecursive(dom.Node node, String parsed) {
4040
if (node is dom.Element) {
4141
List<dom.Element> nodeList = node.nodes.whereType<dom.Element>().toList();
4242
if (node.localName == "math" || node.localName == "mrow") {
43-
nodeList.forEach((element) {
43+
for (var element in nodeList) {
4444
parsed = _parseMathRecursive(element, parsed);
45-
});
45+
}
4646
}
4747
// note: munder, mover, and munderover do not support placing braces and other
4848
// markings above/below elements, instead they are treated as super/subscripts for now.
@@ -52,37 +52,35 @@ String _parseMathRecursive(dom.Node node, String parsed) {
5252
node.localName == "mover") &&
5353
nodeList.length == 2) {
5454
parsed = _parseMathRecursive(nodeList[0], parsed);
55-
parsed = _parseMathRecursive(
55+
parsed = "${_parseMathRecursive(
5656
nodeList[1],
57-
parsed +
58-
"${node.localName == "msup" || node.localName == "mover" ? "^" : "_"}{") +
59-
"}";
57+
"$parsed${node.localName == "msup" || node.localName == "mover" ? "^" : "_"}{")}}";
6058
}
6159
if ((node.localName == "msubsup" || node.localName == "munderover") &&
6260
nodeList.length == 3) {
6361
parsed = _parseMathRecursive(nodeList[0], parsed);
64-
parsed = _parseMathRecursive(nodeList[1], parsed + "_{") + "}";
65-
parsed = _parseMathRecursive(nodeList[2], parsed + "^{") + "}";
62+
parsed = "${_parseMathRecursive(nodeList[1], "${parsed}_{")}}";
63+
parsed = "${_parseMathRecursive(nodeList[2], "$parsed^{")}}";
6664
}
6765
if (node.localName == "mfrac" && nodeList.length == 2) {
68-
parsed = _parseMathRecursive(nodeList[0], parsed + r"\frac{") + "}";
69-
parsed = _parseMathRecursive(nodeList[1], parsed + "{") + "}";
66+
parsed = "${_parseMathRecursive(nodeList[0], parsed + r"\frac{")}}";
67+
parsed = "${_parseMathRecursive(nodeList[1], "$parsed{")}}";
7068
}
7169
// note: doesn't support answer & intermediate steps
7270
if (node.localName == "mlongdiv" && nodeList.length == 4) {
7371
parsed = _parseMathRecursive(nodeList[0], parsed);
74-
parsed = _parseMathRecursive(nodeList[2], parsed + r"\overline{)") + "}";
72+
parsed = "${_parseMathRecursive(nodeList[2], parsed + r"\overline{)")}}";
7573
}
7674
if (node.localName == "msqrt") {
7775
parsed = parsed + r"\sqrt{";
78-
nodeList.forEach((element) {
76+
for (var element in nodeList) {
7977
parsed = _parseMathRecursive(element, parsed);
80-
});
81-
parsed = parsed + "}";
78+
}
79+
parsed = "$parsed}";
8280
}
8381
if (node.localName == "mroot" && nodeList.length == 2) {
84-
parsed = _parseMathRecursive(nodeList[1], parsed + r"\sqrt[") + "]";
85-
parsed = _parseMathRecursive(nodeList[0], parsed + "{") + "}";
82+
parsed = "${_parseMathRecursive(nodeList[1], parsed + r"\sqrt[")}]";
83+
parsed = "${_parseMathRecursive(nodeList[0], "$parsed{")}}";
8684
}
8785
if (node.localName == "mi" ||
8886
node.localName == "mn" ||

0 commit comments

Comments
 (0)