1

I am developing a simple application and in the authentication side i need to use the encrypt package to encrypt jwt tokens but since I installed the encrypt dependency flutter is now giving me this error:

    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.

Alternatively do you know any other library to encrypt strings?

  • 1
    Appearently the encrypt library cannot be used at the moment in flutter web, a solution is to switch to the ninja library. –  Jul 05 '21 at 18:24

2 Answers2

4

pointycastle-3.1.3 does not have full support for the web.

If it is a package you added as a dependency in your pubspec.yaml, then upgrade it to a pre-release version;

dependencies:
  pointycastle: ^3.2.0-rc0

But if it is a dependency on another package you imported, then add the pre-release version as dependency override;

dependency_overrides:
  pointycastle: ^3.2.0-rc0
Loïc Fonkam
  • 2,284
  • 11
  • 25
2

I don't have enough reputation to comment on previous answer, but there's something to correct:

dependency_overrides:

instead of

dependency_override: