Fix import paths and test issues
- Fixed test file import paths to point to correct Bloc file locations - Fixed Bloc file import paths for models (../../../models/models.dart) - Added explicit type annotations to resolve null safety warnings - Fixed null safety issues in wishlist_bloc_test.dart - All 70 tests now passing
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'settings_event.dart';
|
||||
import 'settings_state.dart';
|
||||
|
||||
class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
|
||||
SettingsBloc() : super(SettingsState.initial()) {
|
||||
on<LoadSettings>(_onLoadSettings);
|
||||
on<UpdateTheme>(_onUpdateTheme);
|
||||
on<UpdateLanguage>(_onUpdateLanguage);
|
||||
on<ToggleNotifications>(_onToggleNotifications);
|
||||
on<ClearData>(_onClearData);
|
||||
}
|
||||
|
||||
void _onLoadSettings(LoadSettings event, Emitter<SettingsState> emit) {
|
||||
emit(state.copyWith(
|
||||
isDarkMode: false,
|
||||
language: 'English',
|
||||
notificationsEnabled: true,
|
||||
isLoading: false,
|
||||
));
|
||||
}
|
||||
|
||||
void _onUpdateTheme(UpdateTheme event, Emitter<SettingsState> emit) {
|
||||
emit(state.copyWith(isDarkMode: event.isDarkMode));
|
||||
}
|
||||
|
||||
void _onUpdateLanguage(UpdateLanguage event, Emitter<SettingsState> emit) {
|
||||
emit(state.copyWith(language: event.language));
|
||||
}
|
||||
|
||||
void _onToggleNotifications(
|
||||
ToggleNotifications event, Emitter<SettingsState> emit) {
|
||||
emit(state.copyWith(notificationsEnabled: !state.notificationsEnabled));
|
||||
}
|
||||
|
||||
void _onClearData(ClearData event, Emitter<SettingsState> emit) {
|
||||
emit(state.copyWith(dataCleared: true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user