-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
The JS interop in this package breaks on the latest Flutter dev build which just enabled unsound null-safety enabled by default.
This issue seems to be isolated to dartdevc
as production builds work and doesn't happen on older versions of Flutter/Dart SDK. I'm assuming enabling unsound null-safety should not break existing code right?
This issue can be reproduced by generating a new Flutter web application with the latest dev build, installing the package above, replacing main.dart
with the below:
import 'dart:convert';
import 'package:cryptography/cryptography.dart';
void main() async {
hkdf.deriveKey(
SecretKey.randomBytes(256),
info: utf8.encode('123'),
outputLength: 256,
);
}
and running it on Chrome through flutter run
in debug mode.
In the meantime, is there a way to disable null-safety behaviour in Flutter? Adding // @dart=2.9
to main.dart
doesn't seem to disable unsound null-safety. Is that intentional?
Flutter: 1.26.0-1.0.pre
Dart: 2.12.0-141.0.dev
OS: MacOS Big Sur
Full output:
Launching lib/main.dart on Chrome in debug mode...
lib/main.dart:1
Debug service listening on ws://127.0.0.1:64418/5GhTnQuSyFk=/ws
Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Connecting to VM Service at ws://127.0.0.1:64418/5GhTnQuSyFk=/ws
Error: Expected a value of type 'FutureOr<JSObject<CryptoKey>>?', but got one of type 'CryptoKey'
at Object.throw_ [as throw] (http://localhost:64376/dart_sdk.js:5287:11)
at Object.castError (http://localhost:64376/dart_sdk.js:5258:15)
at Object.cast [as as] (http://localhost:64376/dart_sdk.js:5574:17)
at dart.NullableType.new.as (http://localhost:64376/dart_sdk.js:7122:60)
at http://localhost:64376/dart_sdk.js:60635:139