account for changed itineraries once landmarks are marked as done or deleted
This commit is contained in:
		| @@ -29,9 +29,10 @@ final class Landmark extends LinkedListEntry<Landmark>{ | ||||
|   final Duration? duration; | ||||
|   bool visited; | ||||
|  | ||||
|   // Next node | ||||
|   // Next node is implicitly available through the LinkedListEntry mixin | ||||
|   // final Landmark? next; | ||||
|   final Duration? tripTime; | ||||
|   Duration? tripTime; | ||||
|   // the trip time depends on the next landmark, so it is not final | ||||
|  | ||||
|  | ||||
|   Landmark({ | ||||
|   | ||||
| @@ -75,8 +75,16 @@ class Trip with ChangeNotifier { | ||||
|     notifyListeners(); | ||||
|   } | ||||
|  | ||||
|   void removeLandmark(Landmark landmark) { | ||||
|   void removeLandmark (Landmark landmark) async { | ||||
|     Landmark? previous = landmark.previous; | ||||
|     Landmark? next = landmark.next; | ||||
|     landmarks.remove(landmark); | ||||
|     // removing the landmark means we need to recompute the time between the two adjoined landmarks | ||||
|     if (previous != null && next != null) { | ||||
|       // previous.next = next happens automatically since we are using a LinkedList | ||||
|       previous.tripTime = null; | ||||
|       // TODO | ||||
|     } | ||||
|     notifyListeners(); | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user