mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Check token info and update to new info
This commit is contained in:
@@ -1 +1,10 @@
|
||||
export './device_other.dart' if (dart.library.html) './device_web.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
Future<String?> get clientVersion async {
|
||||
try {
|
||||
return (await PackageInfo.fromPlatform()).version;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
String? get device => null;
|
||||
const _platform = MethodChannel("lifegpc.eh_downloader_flutter/device");
|
||||
final _log = Logger("platformDevice");
|
||||
String? _device;
|
||||
|
||||
Future<String?> get device async {
|
||||
if (_device == null) {
|
||||
try {
|
||||
_device = await _platform.invokeMethod<String>("deviceName");
|
||||
} catch (e) {
|
||||
_log.warning("Failed to get device:", e);
|
||||
}
|
||||
}
|
||||
return _device;
|
||||
}
|
||||
|
||||
String? get clientPlatform {
|
||||
if (Platform.isAndroid) return "android";
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:ua_parser_js/ua_parser_js.dart';
|
||||
final _uaParser = UAParser();
|
||||
String? _device;
|
||||
|
||||
String? get device {
|
||||
Future<String?> get device {
|
||||
if (_device == null) {
|
||||
final ua = _uaParser.getResult();
|
||||
_device = ua.browser.name;
|
||||
@@ -11,7 +11,7 @@ String? get device {
|
||||
_device = "$_device ${ua.browser.version}";
|
||||
}
|
||||
}
|
||||
return _device;
|
||||
return Future.value(_device);
|
||||
}
|
||||
|
||||
String? get clientPlatform => "web";
|
||||
|
||||
Reference in New Issue
Block a user