From 9b266f20cdddda4bb4c4d10160aaba2f125ef170 Mon Sep 17 00:00:00 2001 From: simrat39 Date: Sun, 28 Feb 2021 16:17:42 -0800 Subject: [PATCH] AnimeInfoPage: Dont register EpisodeWatchedProvider Not worth it --- lib/pages/anime_info_page/AnimeInfoPage.dart | 6 +++--- lib/pages/anime_info_page/episodes/EpisodeCard.dart | 4 ++-- lib/pages/anime_info_page/episodes/EpisodesSliver.dart | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pages/anime_info_page/AnimeInfoPage.dart b/lib/pages/anime_info_page/AnimeInfoPage.dart index 630a596..1dfd83e 100644 --- a/lib/pages/anime_info_page/AnimeInfoPage.dart +++ b/lib/pages/anime_info_page/AnimeInfoPage.dart @@ -127,9 +127,6 @@ class _AnimeInfoPageState extends State { return EpisodesWatchedProvider(slug: widget.twistModel.slug); }, ); - Get.delete(); - Get.put>( - _episodesWatchedProvider); await context.read(_episodesWatchedProvider).getWatchedPref(); @@ -391,6 +388,7 @@ class _AnimeInfoPageState extends State { ), EpisodesSliver( episodes: episodes, + episodesWatchedProvider: _episodesWatchedProvider, ), SliverToBoxAdapter( child: SizedBox( @@ -606,6 +604,8 @@ class _AnimeInfoPageState extends State { ), ), EpisodesSliver( + episodesWatchedProvider: + _episodesWatchedProvider, episodes: episodes, ), ], diff --git a/lib/pages/anime_info_page/episodes/EpisodeCard.dart b/lib/pages/anime_info_page/episodes/EpisodeCard.dart index 6ada291..7171533 100644 --- a/lib/pages/anime_info_page/episodes/EpisodeCard.dart +++ b/lib/pages/anime_info_page/episodes/EpisodeCard.dart @@ -23,12 +23,12 @@ class EpisodeCard extends StatelessWidget { final TwistModel twistModel = Get.find(); final KitsuModel kitsuModel = Get.find(); - final ChangeNotifierProvider - episodesWatchedProvider = Get.find(); + final ChangeNotifierProvider episodesWatchedProvider; EpisodeCard({ @required this.episodes, @required this.episodeModel, + @required this.episodesWatchedProvider, }); @override diff --git a/lib/pages/anime_info_page/episodes/EpisodesSliver.dart b/lib/pages/anime_info_page/episodes/EpisodesSliver.dart index 8998c84..3c80507 100644 --- a/lib/pages/anime_info_page/episodes/EpisodesSliver.dart +++ b/lib/pages/anime_info_page/episodes/EpisodesSliver.dart @@ -1,16 +1,20 @@ // Flutter imports: +import 'package:anime_twist_flut/providers/EpisodesWatchedProvider.dart'; import 'package:flutter/material.dart'; // Project imports: import 'package:anime_twist_flut/models/EpisodeModel.dart'; import 'package:anime_twist_flut/pages/anime_info_page/episodes/EpisodeCard.dart'; +import 'package:flutter_riverpod/all.dart'; class EpisodesSliver extends StatelessWidget { final List episodes; + final ChangeNotifierProvider episodesWatchedProvider; EpisodesSliver({ Key key, @required this.episodes, + @required this.episodesWatchedProvider, }) : super(key: key); @override @@ -39,6 +43,7 @@ class EpisodesSliver extends StatelessWidget { child: EpisodeCard( episodeModel: episodes.elementAt(index), episodes: episodes, + episodesWatchedProvider: episodesWatchedProvider, ), ); },