import 'dart:ui'; import 'package:bluebubbles/main.dart'; import 'package:bluebubbles/models/models.dart'; import 'package:bluebubbles/services/services.dart'; import 'package:flutter/material.dart'; import 'package:path/path.dart' show join; class BackgroundIsolate { static void initialize() { CallbackHandle callbackHandle = PluginUtilities.getCallbackHandle(backgroundIsolateEntrypoint)!; mcs.invokeMethod("initialize-background-handle", {"handle": callbackHandle.toRawHandle()}); } } @pragma('vm:entry-point') backgroundIsolateEntrypoint() async { // can't use logger here debugPrint("(ISOLATE) Starting up..."); WidgetsFlutterBinding.ensureInitialized(); ls.isUiThread = false; await ss.init(headless: true); await fs.init(headless: true); await mcs.init(headless: true); debugPrint("Trying to attach to an existing ObjectBox store"); try { store = Store.attach(getObjectBoxModel(), join(fs.appDocDir.path, 'objectbox')); } catch (e, s) { debugPrint(e.toString()); debugPrint(s.toString()); debugPrint("Failed to attach to existing store, opening from path"); try { store = await openStore(directory: join(fs.appDocDir.path, 'objectbox')); } catch (e, s) { debugPrint(e.toString()); debugPrint(s.toString()); } } debugPrint("Opening boxes"); attachmentBox = store.box(); chatBox = store.box(); contactBox = store.box(); fcmDataBox = store.box(); handleBox = store.box(); messageBox = store.box(); scheduledBox = store.box(); themeBox = store.box(); storeStartup.complete(); }