cleanup code a bit

This commit is contained in:
Rene Kievits
2025-10-28 01:59:41 +01:00
parent ab86f015c1
commit 59fde3457d
9 changed files with 62 additions and 56 deletions

View File

@@ -102,7 +102,7 @@ class _HomeScreenState extends State<HomeScreen> {
final pickedType = choices[_random.nextInt(choices.length)];
final readingsList = pickedType == 'onyomi' ? item.onyomi : item.kunyomi;
final hint = 'Select the ${pickedType == 'onyomi' ? "on\'yomi" : "kunyomi"}';
final hint = 'Select the ${pickedType == 'onyomi' ? "on'yomi" : "kunyomi"}';
return _ReadingInfo(readingsList, hint);
}

View File

@@ -26,11 +26,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
final repo = Provider.of<DeckRepository>(context, listen: false);
await repo.setApiKey(apiKey);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('API key saved!')),
);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('API key saved!')),
);
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (_) => const HomeScreen()),
);

View File

@@ -32,7 +32,9 @@ class DistractorGenerator {
if (c.toLowerCase() == correctMeaning.toLowerCase()) continue;
out.add(_toTitleCase(c));
}
while (out.length < needed) out.add('(no more)');
while (out.length < needed) {
out.add('(no more)');
}
return out;
}
@@ -44,7 +46,9 @@ class DistractorGenerator {
if (out.length >= needed) break;
out.add(o);
}
while (out.length < needed) out.add('');
while (out.length < needed) {
out.add('');
}
return out;
}
@@ -61,7 +65,9 @@ class DistractorGenerator {
if (out.length >= needed) break;
out.add(r);
}
while (out.length < needed) out.add('');
while (out.length < needed) {
out.add('');
}
return out;
}
}