Files
GitJournal/lib/main.dart
Vishesh Handa 9499cea164 Remove Settings global
Stop it being a singleton. This means it needs to be passed around a
lot. This sucks, but it's how it should be. I shouldn't be using a
global variable to get around this.

This is needed as Settings will soon become repo specific when we
support multiple repos.

This breaks saving the settings in a file, that feature was toggled off
anyway. It needs to be thought over again.
2020-10-09 00:59:19 +02:00

35 lines
1.0 KiB
Dart

import 'dart:async';
import 'dart:isolate';
import 'package:flutter/foundation.dart' as foundation;
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:gitjournal/app.dart';
import 'package:gitjournal/app_settings.dart';
import 'package:gitjournal/error_reporting.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
var pref = await SharedPreferences.getInstance();
AppSettings.instance.load(pref);
JournalApp.isInDebugMode = foundation.kDebugMode;
FlutterError.onError = flutterOnErrorHandler;
Isolate.current.addErrorListener(RawReceivePort((dynamic pair) async {
var isolateError = pair as List<dynamic>;
assert(isolateError.length == 2);
assert(isolateError.first.runtimeType == Error);
assert(isolateError.last.runtimeType == StackTrace);
await reportError(isolateError.first, isolateError.last);
}).sendPort);
runZonedGuarded(() async {
await JournalApp.main(pref);
}, reportError);
}