What I want to obtain is a method of generating widgets through a predefined step sequence: widget1 -> widget 2-> widget3 -> done. And I thought of making a list of the widgets, and the way to "advance" to the next widget, would be to call moveNext() on the iterator. But clearly I'm missing something:
According to the docs here, if moveNext() is called on the iterator and it returned true, then afterwards the iterator.current will not be null. When printing print(hasAdvanced) it returns true, so iterator.current should not be null. But it is. Why is it null? What am I missing?
import 'package:flutter/material.dart';
class CreatePageWidget extends StatefulWidget {
@override
_CreatePageState createState() => _CreatePageState();
}
class _CreatePageState extends State<CreatePageWidget> {
List<Widget> sequence = [Text("one"), Text("two")];
@override
void initState() {
super.initState();
bool hasAdvanced = sequence.iterator.moveNext();
print(hasAdvanced);
print(sequence.iterator.current);
}
@override
Widget build(BuildContext context) => sequence.iterator.current;
}