Add midnight fallback notice, overnight simulations, and keyboard log filter

This commit is contained in:
dwindown
2026-04-07 11:27:39 +07:00
parent 414450125d
commit c1eade84ab
8 changed files with 1989 additions and 1615 deletions

View File

@@ -13,15 +13,35 @@ import 'core/sacred_tokens.dart';
import 'data/local/models.dart';
import 'features/home/home_view.dart';
const String _duplicateKeyDownAssertion =
'A KeyDownEvent is dispatched, but the state shows that the physical key is already pressed.';
bool _isIgnorableKeyboardAssertion(Object error, [StackTrace? stack]) {
final text = error.toString();
if (!text.contains(_duplicateKeyDownAssertion)) return false;
final stackText = stack?.toString() ?? '';
return stackText.isEmpty || stackText.contains('hardware_keyboard.dart');
}
bool _isIgnorableFlutterAssertion(FlutterErrorDetails details) {
return _isIgnorableKeyboardAssertion(details.exception, details.stack);
}
void main() {
runZonedGuarded(() async {
WidgetsFlutterBinding.ensureInitialized();
FlutterError.onError = (details) {
if (_isIgnorableFlutterAssertion(details)) {
return;
}
FlutterError.presentError(details);
debugPrint('[Fatal][FlutterError] ${details.exceptionAsString()}');
};
PlatformDispatcher.instance.onError = (error, stack) {
if (_isIgnorableKeyboardAssertion(error, stack)) {
return true;
}
debugPrint('[Fatal][PlatformDispatcher] $error');
debugPrintStack(stackTrace: stack);
return true;
@@ -104,8 +124,7 @@ Future<void> _sanitizeMediaSettings(Box<AppSettings> settingsBox) async {
? settings.brandedBgImage
: null;
final needsSave =
validSlides.length != settings.slideshowImages.length ||
final needsSave = validSlides.length != settings.slideshowImages.length ||
brandedBg != settings.brandedBgImage;
if (!needsSave) return;