import 'package:flutter/services.dart';
import 'package:logger/logger.dart';

import '../../Controller/port_controller.dart';

/// Initialisiert benötigte Services in Background-Isolates
Future<void> initBackground() async {
  final Logger logger = Logger()..d('Init Background for Native');

  final RootIsolateToken? rootIsolateToken = await PortController()
      .getRootIsolateToken();
  if (rootIsolateToken != null) {
    logger.i('Initialising BackgroundIsolateBinaryMessenger...');
    BackgroundIsolateBinaryMessenger.ensureInitialized(rootIsolateToken);
  }
}
