Add service client support

This commit is contained in:
2022-07-21 18:33:23 +02:00
parent 327d7dfac6
commit 1774306b06
6 changed files with 338 additions and 46 deletions

52
templates/Dart/base.dart Normal file
View File

@ -0,0 +1,52 @@
class JRPCError extends Error {
String message;
JRPCError(this.message);
@override
String toString() => message;
}
int? int_fromJson(dynamic val) {
if (val == null) {
return null;
} else if (val is int) {
return val;
} else if (val is double) {
return val.toInt();
} else {
throw JRPCError("Not a number!");
}
}
double? double_fromJson(dynamic val) {
if (val == null) {
return null;
} else if (val is int) {
return val.toDouble();
} else if (val is double) {
return val;
} else {
throw JRPCError("Not a number!");
}
}
bool? bool_fromJson(dynamic val) {
if (val == null) {
return null;
} else if (val is bool) {
return val;
} else {
throw JRPCError("Not a bool!");
}
}
String? String_fromJson(dynamic val) {
if (val == null) {
return null;
} else if (val is String) {
return val;
} else {
return val.toString(); // TODO: Either this or error
// throw JRPCError("Not a string!");
}
}