I am writing my first Flutter app, and I use the scoped model to manage global state. I have an issue that when I update one object of a class it also updates another class list containing the same type of objects. I am suspecting its my misconception but I am stuck in my thinking and spinning my wheels.
here is the code
import 'package:flutter/material.dart';
import './wellbeing.dart';
import './activity.dart';
import 'package:scoped_model/scoped_model.dart';
import 'package:date_utils/date_utils.dart';
mixin EventModel on Model {
Map<DateTime, List<Activity>> _events = {};
Activity currentActivity;
Wellbeing currentWellbeing;
String activityType;
DateTime submitDate = DateTime.now();
void updateCurrentActivity(String attribute, int value) {
switch (attribute) {
case 'Intensity':
{
currentActivity.intensity = value;
return;
}
case 'Duration':
{
currentActivity.duration = value;
return;
}
}
}
currentActivity.duration also updates _events[date][0].duration
I have watched this happen in the debugger.