Persist Provider data across multiple pages not working Persist Provider data across multiple pages not working dart dart

Persist Provider data across multiple pages not working


You have 2 options:

  1. Place your ChangeNotifierProvider above your MaterialApp so that is accesible from any of you Navigator routes.

  2. Keep your Home widget as is but when pushing the new widget with the Navigator provide the original Manager.

onTap: () {    Navigator.push(        context,        MaterialPageRoute(            builder: (context) {                return Provider<ToDoListManager>.value(                    value: toDoListManager,                    child: Details(index),                );            },        ),    );},

With both approaches you don't need to create a new ChangeNotifierProvider in your details screen.