revealIfNeeded static method

Future revealIfNeeded(
  1. BuildContext context
)

Implementation

static Future revealIfNeeded(BuildContext context) async {
  final IAppDataStore appDataStore = getObject();

  final shouldNudgeAppLock = await appDataStore.shouldNudgeAppLock();

  if (!shouldNudgeAppLock) {
    return;
  }

  final isAlreadyEnabled = await appDataStore.isLocalAuthEnabled();

  if (isAlreadyEnabled) {
    await appDataStore.setShouldNudgeAppLock(false);
    return;
  }

  // ignore: use_build_context_synchronously
  final shouldEnable = await _askUserToEnableAppLock(context);

  if (shouldEnable == null) {
    return;
  }

  if (shouldEnable) {
    await appDataStore.setLocalAuthEnabled(true);
  }

  await appDataStore.setShouldNudgeAppLock(false);
}