Only show grade switching Warning when something is entered

This commit is contained in:
Elias Müller 2023-05-30 18:54:55 +02:00
parent a161378c72
commit abacef3d8a

View File

@ -64,6 +64,12 @@ class _GradeAverageState extends State<GradeAverage> {
)).toList(),
onSelected: (e) {
void switchSystem() => setState(() {
grades.clear();
gradeSystem = e;
});
if(grades.isNotEmpty) {
showDialog(context: context, builder: (context) {
return AlertDialog(
title: const Text("Notensystem wechseln"),
@ -73,15 +79,16 @@ class _GradeAverageState extends State<GradeAverage> {
Navigator.of(context).pop();
}, child: const Text("Abbrechen")),
TextButton(onPressed: () {
setState(() {
grades.clear();
gradeSystem = e;
});
switchSystem();
Navigator.of(context).pop();
}, child: const Text("Fortfahren")),
],
);
});
} else {
switchSystem();
}
},
),