How can I write byte array in Dart?

痴心易碎 提交于 2021-02-08 14:12:00

问题


How do I write a byte array in Dart? I want to implement this function, but it is Java code with byte[] in it. Can it be written in Dart as well?

public static byte[] encrypt(byte[] key, byte[] data) throws Exception {
    try {
        return performCipher(Cipher.ENCRYPT_MODE, key, data);
    } catch (Exception e) {
        throw new Exception(e);
    }
}

回答1:


What you are looking for is Uint8List. It is the equivalent of byte[] of Java in Dart. Every single value has an equivalent in another language, so byte[] in a few languages is like:

  1. Java: byte[]
  2. Dart: Uint8List
  3. iOS: FlutterStandardTypedData -> typedDataWithBytes

I recommend looking at the documentation for more: https://flutter.dev/docs/development/platform-integration/platform-channels#codec



来源:https://stackoverflow.com/questions/57291240/how-can-i-write-byte-array-in-dart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!