initialize method
Initializes the platform-specific implementation.
Called after Dart initialization to set up native resources.
Implementation
@override
Future<void> initialize({required LocationConfig config}) async {
try {
await methodChannel.invokeMethod('initialize', {
'timeIntervalSeconds': config.timeIntervalSeconds,
'accuracy': config.accuracy.toString().split('.').last,
'enableBackground': config.enableBackground,
});
// Handle callbacks pushed from native (e.g. permission errors)
methodChannel.setMethodCallHandler(_handleNativeCallback);
// Set up event channel listeners
_setupEventChannels();
} on PlatformException catch (e) {
throw LocationPlatformException(
message: e.message ?? 'Platform initialization failed',
code: e.code,
);
}
}