Skip to content
Snippets Groups Projects

Resolve "Use ApplicationSettings widgets from flutter_custom_toolbox"

6 files
+ 13
60
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 0
30
import 'package:flutter_custom_toolbox/flutter_toolbox.dart';
import 'package:flutter/material.dart';
part 'theme_state.dart';
class ThemeCubit extends HydratedCubit<ThemeModeState> {
ThemeCubit() : super(const ThemeModeState());
void getTheme(ThemeModeState state) {
emit(state);
}
@override
ThemeModeState? fromJson(Map<String, dynamic> json) {
switch (json['themeMode']) {
case 'ThemeMode.dark':
return const ThemeModeState(themeMode: ThemeMode.dark);
case 'ThemeMode.light':
return const ThemeModeState(themeMode: ThemeMode.light);
case 'ThemeMode.system':
default:
return const ThemeModeState(themeMode: ThemeMode.system);
}
}
@override
Map<String, String>? toJson(ThemeModeState state) {
return <String, String>{'themeMode': state.themeMode.toString()};
}
}
Loading