findPredecessorFragment function

Fragment? findPredecessorFragment(
  1. List<FNode> flat,
  2. int index
)

Finds the nearest non-empty plain Fragment predecessor of the element at index in flat. Returns null if none exists. A "plain" Fragment is one that is not an InlineContainerNode.

Implementation

Fragment? findPredecessorFragment(List<FNode> flat, int index) {
  for (int i = index - 1; i >= 0; i--) {
    final f = flat[i];
    if (f is Fragment && f is! InlineContainerNode && f.text.isNotEmpty) {
      return f;
    }
  }
  return null;
}