onAppInit function

Future<AppInfo> onAppInit(
  1. Level rootLogLevel,
  2. FallbackAppInfo fallbackInfo
)

Implementation

Future<AppInfo> onAppInit(
    Level rootLogLevel, FallbackAppInfo fallbackInfo) async {
  await configureLogging(
    LogConfig(
      logLevels: {
        "trippiAuth": Level.WARNING,
        "": Level.INFO,
      },
      handler: LoggingHandler.console(),
    ),
  );

  final package = await PackageInfo.fromPlatform();
  String? appStoreUrl;

  final appID = package.packageName;
  appStoreUrl = infoX.isIOS
      ? (await _calculateAppStoreUrl(appID, fallbackInfo))
      : "https://play.google.com/store/apps/details?id=$appID";

  return AppInfo(
    packageName: package.packageName,
    appName: package.appName,
    appBaseUrl: fallbackInfo.appBaseUrl,
    appVersion: semver.Version.parse(package.version),
    buildNumber: package.buildNumber,
    appStoreUrl: appStoreUrl,
  );
}