Skip to content

Commit b9dd217

Browse files
committed
content [nfc]: Use single and last instead to access child.
This improves readability, especially in the .last case. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 8f62edc commit b9dd217

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/model/content.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ class _ZulipContentParser {
986986
&& divElement.className == "codehilite");
987987

988988
if (divElement.nodes.length != 1) return null;
989-
final child = divElement.nodes[0];
989+
final child = divElement.nodes.single;
990990
if (child is! dom.Element) return null;
991991
if (child.localName != 'pre') return null;
992992

@@ -997,7 +997,7 @@ class _ZulipContentParser {
997997
|| first.localName != 'span'
998998
|| first.nodes.isNotEmpty) return null;
999999
}
1000-
final grandchild = child.nodes[child.nodes.length - 1];
1000+
final grandchild = child.nodes.last;
10011001
if (grandchild is! dom.Element) return null;
10021002
if (grandchild.localName != 'code') return null;
10031003

0 commit comments

Comments
 (0)