initialize method

Future<ReachFive> initialize({
  1. required SdkConfig sdkConfig,
  2. List<ProviderCreator> providerCreators = const [],
  3. Dio? dio,
  4. String? domainPathOverride,
  5. List<Interceptor>? interceptors,
})

initialize function used to create an instance of ReachFive

Implementation

Future<ReachFive> initialize({
  required SdkConfig sdkConfig,
  List<ProviderCreator> providerCreators = const [],
  Dio? dio,
  String? domainPathOverride,
  List<Interceptor>? interceptors,
}) async {
  final reachFiveConfigInterface = await _platform.initialize(
    ReachFiveKeyConverter.toInterface(
      ReachFiveKey(
        sdkConfig: sdkConfig,
        providerCreators: providerCreators,
      ),
    ),
  );

  final basePathOverride =
      domainPathOverride ?? 'https://${sdkConfig.domain}';

  final reachFiveIdentityRepo = ReachFiveIdentityRepo(
    dio: dio,
    basePathOverride: basePathOverride,
    interceptors: interceptors,
  );

  return ReachFive(
    reachFiveKey: ReachFiveKeyConverter.fromInterface(
      reachFiveConfigInterface.reachFiveKey,
    ),
    providers: reachFiveConfigInterface.providers
        .whereType<String>()
        .map(ProviderConverter.fromInterface)
        .toList(),
    identityRepo: reachFiveIdentityRepo,
  );
}