This commit is contained in:
Dain Nilsson 2022-02-08 12:33:24 +01:00
commit cde3b14ef1
No known key found for this signature in database
GPG Key ID: F04367096FBA95E8
2 changed files with 14 additions and 2 deletions

View File

@ -35,7 +35,9 @@ class AboutPage extends ConsumerWidget {
children: [Level.INFO, Level.CONFIG, Level.FINE]
.map((level) => TextButton(
onPressed: () {
ref.read(logLevelProvider.notifier).state = level;
ref
.read(logLevelProvider.notifier)
.setLogLevel(level);
log.info(
'Log level changed to ${level.name.toUpperCase()}');
},

View File

@ -9,6 +9,16 @@ final prefProvider = Provider<SharedPreferences>((ref) {
throw UnimplementedError();
});
final logLevelProvider = StateProvider<Level>((ref) => Logger.root.level);
final logLevelProvider = StateNotifierProvider<LogLevelNotifier, Level>(
(ref) => LogLevelNotifier(Logger.root.level));
class LogLevelNotifier extends StateNotifier<Level> {
LogLevelNotifier(Level level) : super(level);
void setLogLevel(Level level) {
Logger.root.level = level;
state = level;
}
}
final isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux;