addDefaultModelIfMissing method

Future<void> addDefaultModelIfMissing()

Adds the default 'jidoujisho Kinomoto' model to the list of Anki card types.

Implementation

Future<void> addDefaultModelIfMissing() async {
  List<String> models = await getModelList();
  if (!models.contains(AnkiMapping.standardModelName)) {
    methodChannel.invokeMethod('addDefaultModel');

    await showDialog(
      barrierDismissible: true,
      context: _navigatorKey.currentContext!,
      builder: (context) => AlertDialog(
        title: Text(t.info_standard_model),
        content: Text(
          t.info_standard_model_content,
        ),
        actions: [
          TextButton(
            child: Text(t.dialog_close),
            onPressed: () => Navigator.pop(context),
          ),
        ],
      ),
    );
  }
}