This repository has been archived on 2023-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
langue-phundrak-com/web/dart/theme.dart

21 lines
426 B
Dart

import 'dart:html';
void switchTheme(final Element body, String theme) {
body.classes.clear();
body.classes.add(theme);
}
void makeThemeChanger() {
final darkBtn = querySelector('#darkBtn');
final lightBtn = querySelector('#lightBtn');
final body = querySelector('body');
darkBtn.onClick.listen((_) {
switchTheme(body, 'dark');
});
lightBtn.onClick.listen((_) {
switchTheme(body, 'light');
});
}