TF-2667 Create ApplicationVersionWidget to display app version
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:fk_user_agent/fk_user_agent.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
class ApplicationManager {
|
||||
|
||||
final DeviceInfoPlugin _deviceInfoPlugin;
|
||||
|
||||
ApplicationManager(this._deviceInfoPlugin);
|
||||
|
||||
Future<PackageInfo> getPackageInfo() async {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
log('ApplicationManager::getPackageInto: $packageInfo');
|
||||
return packageInfo;
|
||||
}
|
||||
|
||||
Future<String> getVersion() async {
|
||||
final version = (await getPackageInfo()).version;
|
||||
log('ApplicationManager::getVersion: $version');
|
||||
return version;
|
||||
}
|
||||
|
||||
Future<String> getUserAgent() async {
|
||||
try {
|
||||
String userAgent;
|
||||
if (PlatformInfo.isWeb) {
|
||||
final webBrowserInfo = await _deviceInfoPlugin.webBrowserInfo;
|
||||
userAgent = webBrowserInfo.userAgent ?? '';
|
||||
} else {
|
||||
await FkUserAgent.init();
|
||||
userAgent = FkUserAgent.userAgent ?? '';
|
||||
FkUserAgent.release();
|
||||
}
|
||||
return userAgent;
|
||||
} catch(e) {
|
||||
logError('ApplicationManager::getUserAgent: Exception: $e');
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> generateApplicationUserAgent() async {
|
||||
final userAgent = await getUserAgent();
|
||||
final version = await getVersion();
|
||||
return 'Team-Mail/$version $userAgent';
|
||||
}
|
||||
}
|
||||
@@ -185,6 +185,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.4"
|
||||
fk_user_agent:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fk_user_agent
|
||||
sha256: fd6c94e120786985a292d12f61422a581f4e851148d5940af38b819357b8ad0d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
flex_color_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -440,6 +448,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
package_info_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: package_info_plus
|
||||
sha256: "7e76fad405b3e4016cd39d08f455a4eb5199723cf594cd1b8916d47140d93017"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.2.0"
|
||||
package_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_platform_interface
|
||||
sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -75,6 +75,10 @@ dependencies:
|
||||
|
||||
printing: 5.12.0
|
||||
|
||||
package_info_plus: 4.2.0
|
||||
|
||||
fk_user_agent: 2.1.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
Reference in New Issue
Block a user