mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
chore: fix widget binding errors
This commit is contained in:
parent
de61d90938
commit
2822d5dbfd
@ -3,6 +3,7 @@ import 'dart:io';
|
|||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
@ -16,34 +17,38 @@ class AppLogger {
|
|||||||
log = Logger(
|
log = Logger(
|
||||||
level: kDebugMode || (verbose && kReleaseMode) ? Level.all : Level.info,
|
level: kDebugMode || (verbose && kReleaseMode) ? Level.all : Level.info,
|
||||||
);
|
);
|
||||||
|
|
||||||
getLogsPath().then((value) => logFile = value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static R? runZoned<R>(R Function() body) {
|
static R? runZoned<R>(R Function() body) {
|
||||||
FlutterError.onError = (details) {
|
|
||||||
reportError(details.exception, details.stack ?? StackTrace.current);
|
|
||||||
};
|
|
||||||
|
|
||||||
PlatformDispatcher.instance.onError = (error, stackTrace) {
|
|
||||||
reportError(error, stackTrace);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!kIsWeb) {
|
|
||||||
Isolate.current.addErrorListener(
|
|
||||||
RawReceivePort((pair) async {
|
|
||||||
final isolateError = pair as List<dynamic>;
|
|
||||||
reportError(
|
|
||||||
isolateError.first.toString(),
|
|
||||||
isolateError.last,
|
|
||||||
);
|
|
||||||
}).sendPort,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return runZonedGuarded<R>(
|
return runZonedGuarded<R>(
|
||||||
body,
|
() {
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
FlutterError.onError = (details) {
|
||||||
|
reportError(details.exception, details.stack ?? StackTrace.current);
|
||||||
|
};
|
||||||
|
|
||||||
|
PlatformDispatcher.instance.onError = (error, stackTrace) {
|
||||||
|
reportError(error, stackTrace);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!kIsWeb) {
|
||||||
|
Isolate.current.addErrorListener(
|
||||||
|
RawReceivePort((pair) async {
|
||||||
|
final isolateError = pair as List<dynamic>;
|
||||||
|
reportError(
|
||||||
|
isolateError.first.toString(),
|
||||||
|
isolateError.last,
|
||||||
|
);
|
||||||
|
}).sendPort,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getLogsPath().then((value) => logFile = value);
|
||||||
|
|
||||||
|
return body();
|
||||||
|
},
|
||||||
(error, stackTrace) {
|
(error, stackTrace) {
|
||||||
reportError(error, stackTrace);
|
reportError(error, stackTrace);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user