OrtValue.fromMap constructor

OrtValue.fromMap(
  1. Map<String, dynamic> map
)

Creates an OrtValue from a map returned by the platform interface

Implementation

factory OrtValue.fromMap(Map<String, dynamic> map) {
  return OrtValue._(
    id: map['valueId'] as String,
    dataType: OrtDataType.values.firstWhere(
      (dt) => dt.toString() == 'OrtDataType.${map['dataType']}',
      // throw an exception if the data type is not found
      orElse: () => throw ArgumentError('Invalid data type: ${map['dataType']}'),
    ),
    shape: List<int>.from(map['shape'] ?? []),
  );
}