2021-03-14 16:44:29 +00:00
|
|
|
import 'package:comunic/utils/flutter_utils.dart';
|
2022-03-10 17:42:48 +00:00
|
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
2021-02-20 08:24:51 +00:00
|
|
|
import 'package:version/version.dart';
|
2021-02-20 07:58:03 +00:00
|
|
|
|
|
|
|
/// Application version helper
|
|
|
|
///
|
|
|
|
/// @author Pierre Hubert
|
|
|
|
|
|
|
|
class VersionHelper {
|
2022-03-10 18:39:57 +00:00
|
|
|
static PackageInfo? _info;
|
2021-02-20 07:58:03 +00:00
|
|
|
|
|
|
|
static Future<void> ensureLoaded() async {
|
2021-03-14 16:44:29 +00:00
|
|
|
if (!isWeb) _info = await PackageInfo.fromPlatform();
|
2021-02-20 07:58:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Get current version information
|
2022-03-10 18:39:57 +00:00
|
|
|
static PackageInfo? get info => _info;
|
2021-02-20 08:24:51 +00:00
|
|
|
|
|
|
|
/// Get current application version, in parsed format
|
2022-03-10 18:39:57 +00:00
|
|
|
static Version get version => Version.parse(info!.version);
|
2021-02-20 07:58:03 +00:00
|
|
|
}
|