convertObjectToBytes static method

Uint8List convertObjectToBytes(
  1. Object o,
  2. TensorType tensorType
)

Implementation

static Uint8List convertObjectToBytes(Object o, TensorType tensorType) {
  if (o is Uint8List) {
    return o;
  }
  if (o is ByteBuffer) {
    return o.asUint8List();
  }
  List<int> bytes = <int>[];
  if (o is List) {
    for (var e in o) {
      bytes.addAll(convertObjectToBytes(e, tensorType));
    }
  } else {
    return _convertElementToBytes(o, tensorType);
  }
  return Uint8List.fromList(bytes);
}