ohlcCloseValueOrNull static method

double? ohlcCloseValueOrNull(
  1. Object? item
)

Reads the close price from an OHLC/candlestick row.

Supported row shapes mirror the candlestick parser:

  • [open, high, low, close, volume?]
  • [date, open, high, low, close, volume?]
  • {open, high, low, close, volume?}

Implementation

static double? ohlcCloseValueOrNull(Object? item) {
  if (item == null) return null;

  final map = JsonValue.map(item);
  if (map != null) {
    final validatedClose = _ohlcCloseFromMap(map);
    if (validatedClose != null) return validatedClose;
    if (_hasCompleteOhlcMap(map)) return null;
    return numeric(map['close']) ?? yValueOrNull(item);
  }

  if (item is List) {
    final close = _ohlcCloseFromList(item);
    if (close != null) return close;
    if (_hasCompleteOhlcList(item)) return null;
    return yValueOrNull(item);
  }

  return yValueOrNull(item);
}