getFirstFragmentRecursive function
Implementation
Fragment? getFirstFragmentRecursive(InlineContainerNode node) {
var children = node.getChildren();
children = children.where((child) => child is InlineContainerNode || (child is Fragment && child.text.isNotEmpty)).toList();
if (children.isEmpty) return null;
final firstChild = children.first;
if (firstChild is InlineContainerNode) {
return getFirstFragmentRecursive(firstChild as InlineContainerNode);
}
return firstChild as Fragment;
}