'Specified language version is too high error while compiling a dart project to executable
I am compiling dart file to exe, following is the code,
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:cryptography/cryptography.dart';
main() async {
var server=await HttpServer.bind(InternetAddress.loopbackIPv4, 8080);
server.listen((event) {
if(event.uri=="/getSecret")
{
utf8.decodeStream(event).then((value) {
var json= jsonDecode(value);
var clientpublickey= json['clientkey'];
var algorithm=Diffie.getAlgorithm();
Diffie.getKeyPair(algorithm).then((keys) {
keys.extractPublicKey().then((publicKey){
var serverpublickey=base64Encode(publicKey.bytes);
Diffie.computeSecret(algorithm, keys, SimplePublicKey(List.from(Uint8List.fromList(base64Decode(clientpublickey))).cast<int>(), type: algorithm.keyPairType)).then((secret) {
event.response.write({
"secret":secret,
"serverpublickey":serverpublickey,
});
event.response.close();
});
});
});
});
}
else
{
event.response.write({
"result": false,
"error": "Invalid url."
});
event.response.close();
}
});
}
class Diffie {
static X25519 getAlgorithm()
{
return X25519();
}
static Future<SimpleKeyPair> getKeyPair(X25519 algorithm) async
{
return await algorithm.newKeyPair();
}
static Future<SimplePublicKey> getPublickey(SimpleKeyPair simpleKeyPair) async
{
return await simpleKeyPair.extractPublicKey();
}
static Future<String> computeSecret(X25519 algorithm, SimpleKeyPair keyPair, SimplePublicKey remotePublicKey) async
{
return base64Encode(await (await algorithm.sharedSecretKey(keyPair: keyPair, remotePublicKey: remotePublicKey)).extractBytes());
}
}
I am using 'cryptography' plugin here. When i try to compile I get the following error
bin/main.dart:1:1: Error: The specified language version is too high. The highest supported language version is 2.10.
What should i do? I am building a dart server. I intend to upload this file to git and send it to ec2 linux server and run it as dart could not be installed on linux ec2 instance. Please help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
