Skip to content

Commit

Permalink
Fixed issue #3 catogory count in drawer not updating on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayak5002 committed Aug 28, 2022
1 parent 4258077 commit 101ad7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions lib/Data/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class Data extends ChangeNotifier{
Data() {
allShows.clear();
loadAllShows();
distribute();
}

void loadAllShows() async {
Expand All @@ -39,9 +38,9 @@ class Data extends ChangeNotifier{
allShows = [];
}

notifyListeners();
distribute();

return;
notifyListeners();
}

void saveAllShows() async{
Expand Down
12 changes: 6 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,37 +125,37 @@ class _MyHomePageState extends State<MyHomePage> {
leading: const Icon(Icons.list),
title: const Text('All'),
onTap: () => selectDrawerItem(context, 0),
trailing: Text(Provider.of<Data>(context).getCount(0).toString(), style: const TextStyle(fontWeight: FontWeight.bold),),
trailing: Text(Provider.of<Data>(context).allShows.length.toString(), style: const TextStyle(fontWeight: FontWeight.bold),),
),
ListTile(
leading: const Icon(CupertinoIcons.clock),
title: const Text('Watching'),
onTap: () => selectDrawerItem(context, 1),
trailing: Text(Provider.of<Data>(context).getCount(1).toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
trailing: Text(Provider.of<Data>(context).watchingShows.length.toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
),
ListTile(
leading: const Icon(Icons.pause),
title: const Text('On-hold'),
onTap: () => selectDrawerItem(context, 2),
trailing: Text(Provider.of<Data>(context).getCount(2).toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
trailing: Text(Provider.of<Data>(context).onHoldShows.length.toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
),
ListTile(
leading: const Icon(CupertinoIcons.cart),
title: const Text('Planned'),
onTap: () => selectDrawerItem(context, 3),
trailing: Text(Provider.of<Data>(context).getCount(3).toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
trailing: Text(Provider.of<Data>(context).plannedShows.length.toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
),
ListTile(
leading: const Icon(Icons.cancel),
title: const Text('Dropped'),
onTap: () => selectDrawerItem(context, 4),
trailing: Text(Provider.of<Data>(context).getCount(4).toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
trailing: Text(Provider.of<Data>(context).droppedShows.length.toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
),
ListTile(
leading: const Icon(Icons.check),
title: const Text('Completed'),
onTap: () => selectDrawerItem(context, 5),
trailing: Text(Provider.of<Data>(context).getCount(5).toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
trailing: Text(Provider.of<Data>(context).completedShows.length.toString(), style: const TextStyle(fontWeight: FontWeight.bold)),
),
],
),
Expand Down

0 comments on commit 101ad7a

Please sign in to comment.