import 'dart:async';

import 'package:dart_framework/log/log.dart';
import 'package:dart_framework/utils/system_util.dart' as system;

class Application {
  Function(Object, StackTrace)? writeLog;

  Application(String name, String appID, Function() func,
      Function(Object, StackTrace) errorListener) {
    runZonedGuarded(() {
      system.initialize(name, appID);
      writeLog = (error, stack) => logError('$error:\n$stack');
      func();
    }, (error, stack) {
      writeLog?.call(error, stack);
      errorListener(error, stack);
    });
  }
}
