findBlockOverrides function Null safety

Map<String, RegularElement> findBlockOverrides(
  1. Element tmpl,
  2. void onError(
    1. JaelError e
    )?
)

Implementation

Map<String, RegularElement> findBlockOverrides(
    Element tmpl, void Function(JaelError e)? onError) {
  var out = <String, RegularElement>{};

  for (var child in tmpl.children) {
    if (child is RegularElement && child.tagName.name == 'block') {
      var name = child.attributes
          .firstWhereOrNull((a) => a.name == 'name')
          ?.value
          ?.compute(SymbolTable()) as String?;
      if (name != null && name.trim().isNotEmpty == true) {
        out[name] = child;
      }
    }
  }

  return out;
}