import 'dart:async'; import 'log.dart'; abstract class Application { Application(Function() func, Function(Object, StackTrace) errorListener) { runZonedGuarded(() async { func(); }, (error, stack) { writeLog(error, stack); errorListener(error, stack); }); } void writeLog(Object error, StackTrace stack) { logError('$error:\n$stack'); } }