NUIMiniProgramFile constructor

NUIMiniProgramFile({
  1. required String filename,
  2. String? bytesString,
  3. required List<String> extensions,
  4. Uint8List? bytes,
})

Implementation

NUIMiniProgramFile({required this.filename, String? bytesString, required this.extensions, Uint8List? bytes}){
  assert(bytesString != null || bytes != null, "Either bytesString or bytes must be provided");

   // If the bytes is provided, convert the bytes from [Uint8List] into base64 to before message transfer
  if(bytes != null) {
    try {
      this.bytesString = base64.encode(bytes);
      print("Set bytes for NUIMiniProgramFile");
    } catch (e) {
      print("[NUIMiniProgramMessage] Failed to base64 encode bytes to bytes string with error: $e");
    }
  }
  else if(bytesString != null){
    this.bytesString = bytesString;
  }
}