runWithReporterAndUiErrors function
Handles global errors and sends them to reporter
and async of UiGlobalError.
Designed to wrap the whole main()
function.
WARNING! FlutterWidgetsBinding.ensureInitialized()
must be called inside it, otherwise some errors may not be
caught.
Implementation
void runWithReporterAndUiErrors(Reporter reporter, void Function(Stream<UiGlobalError> uiErrors) block) {
final controller = StreamController<UiGlobalError>.broadcast();
final handler = GlobalErrorHandler.combine([ReporterGlobalErrorHandler(reporter), _UiGlobalErrorHandler(controller)]);
runWithErrorHandler(handler, () => block(controller.stream));
}