convertObjectToBytes static method

Uint8List convertObjectToBytes(
  1. Object o,
  2. TfLiteType tfliteType
)

Implementation

static Uint8List convertObjectToBytes(Object o, TfLiteType tfliteType) {
  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, tfliteType));
    }
  } else {
    return _convertElementToBytes(o, tfliteType);
  }
  return Uint8List.fromList(bytes);
}