init method
Implementation
@mustCallSuper
@override
Future<void> init() async {
try {
debugPrint("BackgroundTaskManager init start $isInitialized");
if (isInitialized == true) return;
if (_startedInitialization) return;
_isInitialized = false;
//* Initialize result Stream
_resultEventStream ??= _resultEventChannel.receiveBroadcastStream();
_resultStreamSubscription = _resultEventStream?.listen((event) {
print("Result Stream on init : $event");
print("Result Stream on init, Background Event : ${BackgroundEvent.fromMap(event)}");
_internalResultEventStream.add(event);
});
final initValue = await _methodChannel.invokeMethod("initialize");
if (initValue is bool) {
_isInitialized = initValue;
}
if (_isInitialized != true) throw Exception("Failed");
final appDocDir = await getApplicationDocumentsDirectory();
Hive.init(appDocDir.path);
await cache.init();
initCompletable.complete(_isInitialized);
debugPrint("BackgroundTaskManager init success");
} on Exception catch (e) {
debugPrint("BackgroundTaskManager init exception $e");
initCompletable.complete(false);
rethrow;
} on Error catch (e) {
debugPrint("BackgroundTaskManager init error $e");
initCompletable.complete(false);
rethrow;
}
}