mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-08-10 21:20:18 +02:00
offline options globally toggleable
This commit is contained in:
+33
-1
@@ -17,12 +17,44 @@ import 'services/localization_service.dart';
|
||||
import 'services/provider_tile_cache_manager.dart';
|
||||
import 'services/version_service.dart';
|
||||
import 'services/deep_link_service.dart';
|
||||
import 'services/deflock_tile_provider.dart' show TileLoadCancelledException, TileNotAvailableOfflineException;
|
||||
|
||||
|
||||
/// Suppress console noise for expected, already-handled tile load errors.
|
||||
///
|
||||
/// [TileLoadCancelledException] (tile scrolled off screen) and
|
||||
/// [TileNotAvailableOfflineException] (no cached data available) are thrown
|
||||
/// deliberately by DeflockOfflineTileImageProvider and are already handled —
|
||||
/// TileLayerManager.onTileLoadError() specifically skips retry logic for
|
||||
/// both. Flutter's image pipeline reports them via
|
||||
/// MultiFrameImageStreamCompleter with `silent: true`, but
|
||||
/// FlutterError.dumpErrorToConsole has a debug-mode assert() that ignores
|
||||
/// the silent flag and always prints to console anyway. This filters those
|
||||
/// two specific, expected exception types back out while leaving all other
|
||||
/// errors (including genuinely silent-but-unexpected ones) reported as
|
||||
/// normal.
|
||||
void _installTileErrorFilter() {
|
||||
final defaultOnError = FlutterError.onError;
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
final exception = details.exception;
|
||||
if (details.silent &&
|
||||
(exception is TileLoadCancelledException ||
|
||||
exception is TileNotAvailableOfflineException)) {
|
||||
return; // Already handled — don't spam the console.
|
||||
}
|
||||
if (defaultOnError != null) {
|
||||
defaultOnError(details);
|
||||
} else {
|
||||
FlutterError.presentError(details);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
_installTileErrorFilter();
|
||||
|
||||
|
||||
// Initialize version service
|
||||
await VersionService().init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user