initImpl method

  1. @protected
Future<void> initImpl({
  1. RustLibApi? api,
  2. BaseHandler? handler,
  3. ExternalLibrary? externalLibrary,
})
inherited

This is only intended to be used by automatically generated code, instead of developers.

Implementation

@protected
Future<void> initImpl({
  A? api,
  BaseHandler? handler,
  ExternalLibrary? externalLibrary,
}) async {
  if (__state != null) {
    throw StateError('Should not initialize flutter_rust_bridge twice');
  }

  _sanityCheckCodegenVersion();

  externalLibrary ??= await _loadDefaultExternalLibrary();
  handler ??= BaseHandler();
  final generalizedFrbRustBinding =
      GeneralizedFrbRustBinding(externalLibrary);
  _sanityCheckContentHash(generalizedFrbRustBinding);
  final portManager = PortManager(generalizedFrbRustBinding, handler);
  api ??= _createDefaultApi(
      handler, generalizedFrbRustBinding, portManager, externalLibrary);

  __state = _EntrypointState(
    generalizedFrbRustBinding: generalizedFrbRustBinding,
    portManager: portManager,
    api: api,
  );

  await executeRustInitializers();
}