【问题标题】:How can I write byte array in Dart?如何在 Dart 中写入字节数组?
【发布时间】:2019-12-09 00:02:12
【问题描述】:

如何在 Dart 中编写字节数组?我想实现这个功能,但它是带有byte[] 的Java 代码。也可以用 Dart 写吗?

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);
    }
}

【问题讨论】:

    标签: java flutter dart


    【解决方案1】:

    您正在寻找的是Uint8List。它相当于 Dart 中 Java 的byte[]。每个单独的值在另一种语言中都有一个等价物,所以 byte[] 在几种语言中就像:

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

    我建议查看文档以了解更多信息:https://flutter.dev/docs/development/platform-integration/platform-channels#codec

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-18
      • 2014-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-18
      • 2010-12-18
      相关资源
      最近更新 更多