yValueOrNull static method
Implementation
static double? yValueOrNull(Object? item) {
if (item == null) return null;
final scalar = numeric(item);
if (scalar != null) return scalar;
if (item is List) {
if (item.length > 1) {
final y = numeric(item[1]);
if (y != null) return y;
}
if (item.isNotEmpty) {
final first = numeric(item.first);
if (first != null) return first;
}
if (item.isNotEmpty) {
final last = numeric(item.last);
if (last != null) return last;
}
return null;
}
final map = JsonValue.map(item);
if (map != null) {
if (_hasCompleteOhlcMap(map)) {
return _ohlcCloseFromMap(map);
}
for (final key in const [
'y',
'value',
'close',
'mean',
'amount',
'count',
'size',
]) {
final value = numeric(map[key]);
if (value != null) return value;
}
return null;
}
try {
final dynamic dynamicItem = item;
return numeric(dynamicItem.value);
} catch (_) {
return null;
}
}