getNestedField method
Retrieves a nested field from a JSON-like Firestore document.
data
: The document data as aMap<String, dynamic>
.path
: The JSON path to the nested field (e.g., "data/lastUpdatedTime").
Returns the field value, or null
if the path doesn't exist.
Implementation
dynamic getNestedField(Map<String, dynamic> data, String path) {
final keys = path.split('/');
dynamic current = data;
for (var key in keys) {
if (current is Map<String, dynamic> && current.containsKey(key)) {
current = current[key];
} else {
debugPrint("Key '$key' not found in path $path.");
return null;
}
}
return parseFirestoreData(current);
}