Skip to content

Commit 4917d09

Browse files
committed
feat(app): pass environment to AppState
- Added environment variable - Passed to AppState constructor
1 parent f669839 commit 4917d09

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/app/bloc/app_bloc.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:flex_color_scheme/flex_color_scheme.dart';
66
import 'package:flutter/material.dart';
77
import 'package:ht_auth_repository/ht_auth_repository.dart';
88
import 'package:ht_data_repository/ht_data_repository.dart';
9+
import 'package:ht_main/app/config/config.dart' as local_config;
910
import 'package:ht_shared/ht_shared.dart'; // Import shared models and exceptions
1011

1112
part 'app_event.dart';
@@ -15,24 +16,23 @@ class AppBloc extends Bloc<AppEvent, AppState> {
1516
AppBloc({
1617
required HtAuthRepository authenticationRepository,
1718
required HtDataRepository<UserAppSettings> userAppSettingsRepository,
18-
required HtDataRepository<AppConfig> appConfigRepository, // Added
19-
}) : _authenticationRepository = authenticationRepository,
20-
_userAppSettingsRepository = userAppSettingsRepository,
21-
_appConfigRepository = appConfigRepository, // Added
22-
// Initialize with default state, load settings after user is known
23-
// Provide a default UserAppSettings instance
24-
super(
25-
// AppConfig will be null initially, fetched later
26-
const AppState(
27-
settings: UserAppSettings(id: 'default'),
28-
selectedBottomNavigationIndex: 0,
29-
appConfig: null,
30-
),
31-
) {
19+
required HtDataRepository<AppConfig> appConfigRepository,
20+
required local_config.AppEnvironment environment, // Added
21+
}) : _authenticationRepository = authenticationRepository,
22+
_userAppSettingsRepository = userAppSettingsRepository,
23+
_appConfigRepository = appConfigRepository,
24+
super(
25+
AppState(
26+
settings: const UserAppSettings(id: 'default'),
27+
selectedBottomNavigationIndex: 0,
28+
appConfig: null,
29+
environment: environment, // Pass environment to AppState
30+
),
31+
) {
3232
on<AppUserChanged>(_onAppUserChanged);
3333
on<AppSettingsRefreshed>(_onAppSettingsRefreshed);
3434
on<AppConfigFetchRequested>(_onAppConfigFetchRequested);
35-
on<AppUserAccountActionShown>(_onAppUserAccountActionShown); // Added
35+
on<AppUserAccountActionShown>(_onAppUserAccountActionShown);
3636
on<AppLogoutRequested>(_onLogoutRequested);
3737
on<AppThemeModeChanged>(_onThemeModeChanged);
3838
on<AppFlexSchemeChanged>(_onFlexSchemeChanged);

0 commit comments

Comments
 (0)