getKeyValue method
return a list if keyPath is an array
if keyPath
is a, the list cannot contain null values and null is returned instead.
Implementation
Object? getKeyValue(Object? keyPath) {
if (keyPath is String) {
return getFieldValue(keyPath);
} else if (keyPath is List) {
final keyList = keyPath;
var keys = List<Object?>.generate(
keyList.length,
(i) => getFieldValue(keyPath[i] as String),
);
if (keys.where((element) => element == null).isNotEmpty) {
/// the list cannot contain null values
return null;
}
return keys;
}
throw 'keyPath $keyPath not supported';
}