when moving the children around by calling setChildIndex, it
causes the container to loose the selectedIndex reference. This
causes the selectedChild to stay on top of any of the children
before it until it is set at the selectedChild again.
this method should be overriden and the _selectedIndex should
be changed accordingly.
Line 1264 & 1265 are reveresed causing an error when any
child is moved previous to calling removeAllChildren.
1264: selectedIndex = -1;
1265: _selectedIndex = -1;
these lines are executed when the last child has been
when the setter for selectedIndex is called it dispatches a
value commit event, which causes any ChangeWatcher's that are
binded to selectedChild to execute.
these execute before line 1265 is executed causing an (index
is out of bound) exception to be thrown when the ChangeWatcher
tries to get the value for selectedChild.
the container should set _selectedIndex to -1 first, so any
bindings to selectedChild won't cause an exception.