diff --git a/packages/dynamite/dynamite/lib/src/models/type_result/base.dart b/packages/dynamite/dynamite/lib/src/models/type_result/base.dart index 215f0a4c..170d8569 100644 --- a/packages/dynamite/dynamite/lib/src/models/type_result/base.dart +++ b/packages/dynamite/dynamite/lib/src/models/type_result/base.dart @@ -30,7 +30,14 @@ class TypeResultBase extends TypeResult { return '$object.toString()'; } case 'application/octet-stream': - return 'utf8.encode($object) as Uint8List'; + switch (className) { + case 'Uint8List': + return object; + case 'String': + return '(utf8.encode($object) as Uint8List)'; + default: + throw Exception('"$mimeType" can only be Uint8List or String'); + } default: throw Exception('Can not encode mime type "$mimeType"'); }