class SimplePanelIterator implements Iterator<Widget> {
bool hasElement = false;
Widget returned = null;
SimplePanel _panel;
SimplePanelIterator(this._panel) {
hasElement = this._panel.widget != null;
}
/**
* Returns whether the [Iterator] has elements left.
*/
bool moveNext() {
return hasElement;
}
Widget get current => _getCurrent();
/**
* Gets the next element in the iteration. Throws a
* [StateError] if no element is left.
*/
Widget _getCurrent() {
if (!hasElement || (this._panel.widget == null)) {
throw new Exception("NoSuchElement");
}
hasElement = false;
return (returned = this._panel.widget);
}
remove() {
if (returned != null) {
_panel.remove(returned);
}
}
}