initialize method
Initializes the native clients with options.
Must be called once before any tracking method. Repeated calls are ignored and return the future of the first call.
Implementation
Future<void> initialize(OpenpanelOptions options) {
final Completer<void>? existing = _initCompleter;
if (existing != null) {
return existing.future;
}
final Completer<void> completer = Completer<void>();
_initCompleter = completer;
// The platform call never throws (see MethodChannelOpenpanel._guard);
// `whenComplete` also propagates readiness on unexpected failures so
// queued events are not stuck forever.
OpenpanelPlatform.instance
.initialize(options)
.whenComplete(() => _complete(completer));
return completer.future;
}