Modify (add/remove) events programmatically (timetable 1.0.0-alpha)
Opened this issue · 4 comments
I'm trying to modify events (add/remove) events programmatically in alpha version but I can't find related methods to do so.
@JonasWanke I see that in stable version it is defined in section 3, but in alpha version i couldn't reproduce same behaviour this way. How could I modify events in alpha version?
EventProvider.list(List<E> events):
If you have a non-changing list of events.
EventProvider.simpleStream(Stream<List<E>> eventStream):
If you have a limited, changing list of events.
EventProvider.stream({StreamedEventGetter<E> eventGetter}):
If your events can change or you have many events and only want to load the relevant subset.
In the alpha versions, I removed the complexity of using streams to supply events. Instead, you can pass a function of type EventProvider<E>
to timetableConfig.eventProvider
:
TimetableConfig<BasicEvent>(
eventProvider: (interval) {
return myEventsInInterval(interval);
},
// ...
);
If the events you want to display change, you just rebuild the widget and return different events from the callback.
If you have a fixed list of events, you can use the utility function eventProviderFromFixedList(myListOfEvents)
. If you have multiple event providers that you want to merge (i.e., display events from all event providers combined), use mergeEventProviders(myListOfEventProviders)
.
@JonasWanke Thank you for answer, I have tried it and it worked! This is enough for me but additionally if possible can I animate item when it gets removed or added? So that when state changes and newly added item appears with animation?
Timetable doesn't support animations for added or removed events out of the box. However, you control the widgets for each event. Hence, you could wrap a BasicEventWidget
in an AnimatedOpacity
widget that fades in when it is first added. When the event is removed, you would first fade out the widget, and only then remove the actual event from Timetable.
https://flutter.dev/docs/cookbook/animation/opacity-animation
Timetable doesn't support animations for added or removed events out of the box. However, you control the widgets for each event. Hence, you could wrap a
BasicEventWidget
in anAnimatedOpacity
widget that fades in when it is first added. When the event is removed, you would first fade out the widget, and only then remove the actual event from Timetable.https://flutter.dev/docs/cookbook/animation/opacity-animation
That will work too! Thank you for all answers, this issue can be closed!