Vízhányó Balázs b1e68f18b0 Package name fix
2023-05-29 14:48:23 +02:00

38 lines
962 B
Dart

import 'dart:io';
class Config {
String _userAgent;
Map? json;
static const String _version = String.fromEnvironment("APPVER", defaultValue: "2.2.0");
Config({required String userAgent, this.json}) : _userAgent = userAgent;
factory Config.fromJson(Map json) {
return Config(
userAgent: json["user_agent"] ?? "hu.refilc.naplo/\$0/\$1/\$2",
json: json,
);
}
String get userAgent => _userAgent.replaceAll("\$0", _version).replaceAll("\$1", platform).replaceAll("\$2", "0");
static String get platform {
if (Platform.isAndroid) {
return "Android";
} else if (Platform.isIOS) {
return "iOS";
} else if (Platform.isLinux) {
return "Linux";
} else if (Platform.isWindows) {
return "Windows";
} else if (Platform.isMacOS) {
return "MacOS";
} else {
return "Unknown";
}
}
@override
String toString() => json.toString();
}