1

我正在开发一个简单的应用程序,在身份验证方面,我需要使用 encrypt 包来加密 jwt 令牌,但是由于我安装了 encrypt 依赖,flutter 现在给了我这个错误:

    flutter pub add encrypt Launching lib\main.dart on Chrome in debug mode...
    flutter/.pub-cache/hosted/pub.dartlang.org/pointycastle-3.1.3/lib/key_derivators/argon2.dart:42:27:
Error: The integer literal 0xFFFFFFFFFFFFFFFF can't be represented exactly in JavaScript.
    Try changing the literal to something that can be represented in Javascript.
    In Javascript 0x10000000000000000 is the nearest value that can be represented exactly. static const int M32L = 0xFFFFFFFFFFFFFFFF; 
    
    flutter/.pub-cache/hosted/pub.dartlang.org/pointycastle-3.1.3/lib/src/utils.dart:313:9:
Error: The integer literal 0xFFFFFFFFFFFFFFFF can't be represented exactly in JavaScript.
    Try changing the literal to something that can be represented in Javascript.
    In Javascript 0x10000000000000000 is the nearest value that can be represented exactly. ((0xFFFFFFFFFFFFFFFF) ^ ((1 << (64 - count)) - 1));
    
    flutter/.pub-cache/hosted/pub.dartlang.org/pointycastle-3.1.3/lib/src/platform_check/platform_check.dart:6:35: Error: Method not found: 'getPlatform'. static Platform get instance => getPlatform(); Failed to compile application.

或者,您知道任何其他用于加密字符串的库吗?

4

2 回答 2

5

pointycastle-3.1.3 不完全支持网络。

如果它是您在 中添加为依赖项的包pubspec.yaml,则将其升级到预发布版本;

dependencies:
  pointycastle: ^3.2.0-rc0

但如果它是对您导入的另一个包的依赖,则添加预发布版本作为依赖覆盖;

dependency_overrides:
  pointycastle: ^3.2.0-rc0
于 2021-07-12T05:35:31.057 回答
3

我没有足够的声誉来评论以前的答案,但有一些需要纠正的地方:

dependency_overrides:

代替

dependency_override:
于 2021-07-14T17:51:19.100 回答