Skip to content

Commit ec8d5a7

Browse files
committed
fix(app): ensure environment is set in initial AppState
The AppBloc was receiving the AppEnvironment in its constructor but was not setting it in the initial AppState. This resulted in `state.environment` being null throughout the app, causing conditional UI elements (like demo mode hints) to fail to appear. This change passes the environment to the AppState constructor during bloc initialization and removes the now-unused `_environment` field from the AppBloc.
1 parent af2aa48 commit ec8d5a7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/app/bloc/app_bloc.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ class AppBloc extends Bloc<AppEvent, AppState> {
2121
}) : _authenticationRepository = authenticationRepository,
2222
_userAppSettingsRepository = userAppSettingsRepository,
2323
_appConfigRepository = appConfigRepository,
24-
_environment = environment,
2524
super(
26-
const AppState(),
25+
AppState(environment: environment),
2726
) {
2827
on<AppUserChanged>(_onAppUserChanged);
2928
on<AppLogoutRequested>(_onLogoutRequested);
@@ -37,7 +36,6 @@ class AppBloc extends Bloc<AppEvent, AppState> {
3736
final HtAuthRepository _authenticationRepository;
3837
final HtDataRepository<UserAppSettings> _userAppSettingsRepository;
3938
final HtDataRepository<AppConfig> _appConfigRepository;
40-
final local_config.AppEnvironment _environment;
4139
late final StreamSubscription<User?> _userSubscription;
4240

4341
/// Handles user changes and loads initial settings once user is available.

0 commit comments

Comments
 (0)