validateSelectedMapping method
- {required BuildContext context,
- required AnkiMapping mapping}
Check for errors relating to the current selected export profile.
Implementation
Future<void> validateSelectedMapping({
required BuildContext context,
required AnkiMapping mapping,
}) async {
/// Ensure that the following case never happens to the default profile.
await addDefaultModelIfMissing();
bool newMappingModelExists = await profileModelExists(mapping);
if (!newMappingModelExists) {
await showDialog(
barrierDismissible: true,
context: context,
builder: (context) => AlertDialog(
title: Text(t.error_model_missing),
content: Text(
t.error_model_missing_content,
),
actions: [
TextButton(
child: Text(t.dialog_close),
onPressed: () => Navigator.pop(context),
),
],
),
);
await selectStandardProfile();
deleteMapping(mapping);
return;
}
bool newMappingModelLengthMatches =
await profileFieldMatchesCardTypeCount(mapping);
if (!newMappingModelLengthMatches) {
await showDialog(
barrierDismissible: true,
context: context,
builder: (context) => AlertDialog(
title: Text(t.error_model_changed),
content: Text(
t.error_model_changed_content,
),
actions: [
TextButton(
child: Text(t.dialog_close),
onPressed: () => Navigator.pop(context),
),
],
),
);
await resetProfileFields(mapping);
}
}