queryFieldValue function

Object? queryFieldValue(
  1. Map<String, Object?> doc,
  2. String path
)

The value at path in doc: a top-level field, or one level into a map (style.color); null when absent.

Implementation

Object? queryFieldValue(Map<String, Object?> doc, String path) {
  if (!path.contains('.')) return doc[path];
  final parts = path.split('.');
  final parent = doc[parts[0]];
  return parent is Map ? parent[parts[1]] : null;
}