feat: package info
This commit is contained in:
parent
cb45f7db16
commit
de42fc68a4
9
lib/common/di/di_package_info.dart
Normal file
9
lib/common/di/di_package_info.dart
Normal file
@ -0,0 +1,9 @@
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
@module
|
||||
abstract class PackageInfoDi {
|
||||
@preResolve // karena butuh async init
|
||||
@lazySingleton
|
||||
Future<PackageInfo> get packageInfo => PackageInfo.fromPlatform();
|
||||
}
|
||||
@ -15,6 +15,7 @@ import 'package:apskel_owner_flutter/common/api/api_client.dart' as _i115;
|
||||
import 'package:apskel_owner_flutter/common/di/di_auto_route.dart' as _i311;
|
||||
import 'package:apskel_owner_flutter/common/di/di_connectivity.dart' as _i586;
|
||||
import 'package:apskel_owner_flutter/common/di/di_dio.dart' as _i103;
|
||||
import 'package:apskel_owner_flutter/common/di/di_package_info.dart' as _i227;
|
||||
import 'package:apskel_owner_flutter/common/di/di_shared_preferences.dart'
|
||||
as _i402;
|
||||
import 'package:apskel_owner_flutter/common/network/network_client.dart'
|
||||
@ -26,6 +27,7 @@ import 'package:connectivity_plus/connectivity_plus.dart' as _i895;
|
||||
import 'package:dio/dio.dart' as _i361;
|
||||
import 'package:get_it/get_it.dart' as _i174;
|
||||
import 'package:injectable/injectable.dart' as _i526;
|
||||
import 'package:package_info_plus/package_info_plus.dart' as _i655;
|
||||
import 'package:shared_preferences/shared_preferences.dart' as _i460;
|
||||
|
||||
const String _dev = 'dev';
|
||||
@ -42,6 +44,7 @@ extension GetItInjectableX on _i174.GetIt {
|
||||
final dioDi = _$DioDi();
|
||||
final autoRouteDi = _$AutoRouteDi();
|
||||
final connectivityDi = _$ConnectivityDi();
|
||||
final packageInfoDi = _$PackageInfoDi();
|
||||
await gh.factoryAsync<_i460.SharedPreferences>(
|
||||
() => sharedPreferencesDi.prefs,
|
||||
preResolve: true,
|
||||
@ -49,6 +52,10 @@ extension GetItInjectableX on _i174.GetIt {
|
||||
gh.lazySingleton<_i361.Dio>(() => dioDi.dio);
|
||||
gh.lazySingleton<_i258.AppRouter>(() => autoRouteDi.appRouter);
|
||||
gh.lazySingleton<_i895.Connectivity>(() => connectivityDi.connectivity);
|
||||
await gh.lazySingletonAsync<_i655.PackageInfo>(
|
||||
() => packageInfoDi.packageInfo,
|
||||
preResolve: true,
|
||||
);
|
||||
gh.lazySingleton<_i543.NetworkClient>(
|
||||
() => _i543.NetworkClient(gh<_i895.Connectivity>()),
|
||||
);
|
||||
@ -71,3 +78,5 @@ class _$DioDi extends _i103.DioDi {}
|
||||
class _$AutoRouteDi extends _i311.AutoRouteDi {}
|
||||
|
||||
class _$ConnectivityDi extends _i586.ConnectivityDi {}
|
||||
|
||||
class _$PackageInfoDi extends _i227.PackageInfoDi {}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
import '../../../common/extension/extension.dart';
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../injection.dart';
|
||||
import '../../components/assets/assets.gen.dart';
|
||||
import '../../router/app_router.gr.dart';
|
||||
|
||||
@ -94,6 +96,7 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final packageInfo = getIt<PackageInfo>();
|
||||
return Scaffold(
|
||||
body: AnimatedBuilder(
|
||||
animation: Listenable.merge([
|
||||
@ -157,7 +160,7 @@ class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin {
|
||||
child: Opacity(
|
||||
opacity: versionOpacity,
|
||||
child: Text(
|
||||
'${context.lang.version} 1.0.0',
|
||||
'${context.lang.version} ${packageInfo.version}+${packageInfo.buildNumber}',
|
||||
style: AppStyle.md.copyWith(color: AppColor.textLight),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
@ -7,12 +7,14 @@ import Foundation
|
||||
|
||||
import connectivity_plus
|
||||
import file_selector_macos
|
||||
import package_info_plus
|
||||
import path_provider_foundation
|
||||
import shared_preferences_foundation
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
}
|
||||
|
||||
24
pubspec.lock
24
pubspec.lock
@ -805,6 +805,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
package_info_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: package_info_plus
|
||||
sha256: "16eee997588c60225bda0488b6dcfac69280a6b7a3cf02c741895dd370a02968"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "8.3.1"
|
||||
package_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_platform_interface
|
||||
sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
path:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1202,6 +1218,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.14.0"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -38,6 +38,7 @@ dependencies:
|
||||
flutter_bloc: ^9.1.1
|
||||
image_picker: ^1.1.2
|
||||
table_calendar: ^3.2.0
|
||||
package_info_plus: ^8.3.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user