Skip to content

Commit 9e7179f

Browse files
committed
feat(app_state): add currentAppVersion and latestAppVersion for version enforcement
- Add currentAppVersion to AppState for version tracking - Implement latestAppVersion getter for remote config access - Update AppState constructor, copyWith method, and equatable props
1 parent a12b9af commit 9e7179f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/app/bloc/app_state.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class AppState extends Equatable {
4848
this.userContentPreferences,
4949
this.settings,
5050
this.selectedBottomNavigationIndex = 0,
51+
this.currentAppVersion,
5152
});
5253

5354
/// The current status of the application, indicating its lifecycle stage.
@@ -84,6 +85,14 @@ class AppState extends Equatable {
8485
/// The current application environment (e.g., demo, development, production).
8586
final local_config.AppEnvironment environment;
8687

88+
/// The current version of the application, fetched from `package_info_plus`.
89+
/// This is used for version enforcement.
90+
final String? currentAppVersion;
91+
92+
/// The latest required app version from the remote configuration.
93+
/// Returns `null` if remote config is not available.
94+
String? get latestAppVersion => remoteConfig?.appStatus.latestAppVersion;
95+
8796
/// The current theme mode (light, dark, or system), derived from [settings].
8897
/// Defaults to [ThemeMode.system] if [settings] are not yet loaded.
8998
ThemeMode get themeMode {
@@ -152,6 +161,7 @@ class AppState extends Equatable {
152161
userContentPreferences,
153162
selectedBottomNavigationIndex,
154163
environment,
164+
currentAppVersion,
155165
];
156166

157167
/// Creates a copy of this [AppState] with the given fields replaced with
@@ -167,6 +177,7 @@ class AppState extends Equatable {
167177
UserContentPreferences? userContentPreferences,
168178
int? selectedBottomNavigationIndex,
169179
local_config.AppEnvironment? environment,
180+
String? currentAppVersion,
170181
}) {
171182
return AppState(
172183
status: status ?? this.status,
@@ -182,6 +193,7 @@ class AppState extends Equatable {
182193
selectedBottomNavigationIndex:
183194
selectedBottomNavigationIndex ?? this.selectedBottomNavigationIndex,
184195
environment: environment ?? this.environment,
196+
currentAppVersion: currentAppVersion ?? this.currentAppVersion,
185197
);
186198
}
187199
}

0 commit comments

Comments
 (0)