showAnkidroidApiMessage method

void showAnkidroidApiMessage()

Shows the AnkiDroid API message. Called when an Anki-related API get call fails.

Implementation

void showAnkidroidApiMessage() async {
  await requestAnkidroidPermissions();

  await showDialog(
    barrierDismissible: true,
    context: _navigatorKey.currentContext!,
    builder: (context) => AlertDialog(
      title: Text(t.error_ankidroid_api),
      content: Text(
        t.error_ankidroid_api_content,
      ),
      actions: [
        TextButton(
          child: Text(t.dialog_launch_ankidroid),
          onPressed: () async {
            await LaunchApp.openApp(
              androidPackageName: 'com.ichi2.anki',
              openStore: true,
            );
            Navigator.pop(context);
          },
        ),
        TextButton(
          child: Text(t.dialog_close),
          onPressed: () => Navigator.pop(context),
        ),
      ],
    ),
  );
}