I am using provider package to detect changes in 'todaysTasks' but as you can see 'todayTasks' depends on DaysRecords which stores a list of DayTasks, so what I want is to rebuild my root widget (which is MyApp) whenever i push a DayTask in DaysRecords.recordsList but can't figure out any way to do that. Is there any solution to this??
class MyApp extends StatelessWidget {
static const routeName = '/root';
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
DayTasks todaysTasks = DaysRecords.recordsList.last;
return ChangeNotifierProvider(
create: (context) => todaysTasks,
You can just wrap the parent widget of MyApp (I'm guessing, it is MaterialApp on main method) with ChangeNotifierProvider instead of wrapping inside MyApp.
Then initialize the correspondent provider in MyApp's build method or use a consumer to rebuild (manage your state).