Fix editing plan
This commit is contained in:
parent
98991a3d02
commit
dac65c8390
|
@ -103,10 +103,24 @@ class _EditPlanPageState extends State<EditPlanPage> {
|
|||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
final days = [];
|
||||
for (int i = 0; i < daySelections!.length; i++) {
|
||||
if (daySelections![i]) days.add(weekdayNames[i]);
|
||||
}
|
||||
|
||||
final exercises = [];
|
||||
for (int i = 0; i < exerciseSelections!.length; i++) {
|
||||
if (exerciseSelections![i]) exercises.add(names[i]);
|
||||
}
|
||||
|
||||
final newPlan = plan.copyWith(
|
||||
days: Value(days.join(',')),
|
||||
exercises: Value(exercises.join(',')));
|
||||
|
||||
if (plan.id.present)
|
||||
await db.update(db.plans).replace(plan);
|
||||
await db.update(db.plans).replace(newPlan);
|
||||
else
|
||||
await db.into(db.plans).insert(plan);
|
||||
await db.into(db.plans).insert(newPlan);
|
||||
if (!mounted) return;
|
||||
Navigator.pop(context);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user