Switching layouts throws exception
Closed this issue · 2 comments
paolovalerdi commented
Describe the bug
When switching layouts, let's say from MultiDateTimetable
-> RecurringTimetable
, the following exception is thrown.
The following assertion was thrown while dispatching notifications for TimeController:
This widget has been unmounted, so the State no longer has a context (and should be considered defunct).
Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.
When the exception was thrown, this was the stack:
#0 State.context.<anonymous closure> (package:flutter/src/widgets/framework.dart:909:9)
#1 State.context (package:flutter/src/widgets/framework.dart:915:6)
#2 _TimeZoomState._controller (package:timetable/src/time/zoom.dart:32:62)
#3 _TimeZoomState._outerOffset (package:timetable/src/time/zoom.dart:44:23)
#4 _TimeZoomState._onControllerChanged (package:timetable/src/time/zoom.dart:67:31)
...
The TimeController sending notification was: TimeController#4129c(TimeRange(startTime = 4:20:45.998785, endTime = 20:08:54.887674))
The reason seems to be that this callback is never removed from the controller when the TimeZoom
widget is disposed.
paolovalerdi commented
I did fix this issue here, but I'm not quite sure if it's the right approach
JonasWanke commented
Thanks for investigating the cause! This is now fixed as part of v1.0.0-alpha.3.