I have a Flutter app that I built to allow product input into our product library. I am using the library flow_builder
. This library allows me to use a single model to declare the data being stored in a sequence of screens. It works perfectly with regards to this purpose: The flow of the input works perfectly, until I attempt to 'reset' the app to the beginning.
When I get to the end of the flow, I want to be able to start over and add another entry. When I attempt to do this, things break. The behavior I'm seeing is that it will return to the main screen, the values will be erased, but it will not restart the flow.
My flow is defined as:
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return FlowBuilder<FormDetails>(
state: FormDetails(),
onGeneratePages: (product, pages) {
return [
const MaterialPage(child: ProductDetailsForm()),
if (product.name != null)
const MaterialPage(child: ProductLocation()),
if (product.location != null)
const MaterialPage(child: ProductBudgetScreen()),
if (product.budgetAmount != null)
const MaterialPage(child: EndScreenModal())
];
},
);
}
}
And I'm attempting to reset by going to the first page:
TextButton(
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const ProductDetailsForm())),
child: const Text('Start Over'),
)
Part of me suspects that what I want is not possible, but I figured I would ask here before giving up and going a different route.