Comments (2)
Nice @rj-since-2000👏🏻. So you can replace all "consumer" usages with "Provider" wherever necessary and properly test all the functionalities once from your side too before pushing the changes.
from rutorrent-flutter.
@harchani-ritik Probably yes because the switch is actually present in the main screen, so we only need to refresh the main screen and the torrents list on toggle switch. Rest of the widgets can use Provider when they come in focus.
Actually after more research, I realised why do we even need a Consumer in the main screen. Let's try to analyse -
There are three providers - Api, GeneralFeatures and Mode
*(Api does not even extend ChangeNotifierProvider)
Api is used in -
'api.username'
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => MainScreen()));
is already calling the MainScreen to refresh on switching between accounts in the drawer. Thus it doesn't need a consumer to update in the UI.
'_getAccountsList(api, modeTheme, general)' in Drawer
Same as above
if (_currentIndex == 0) { showModalBottomSheet( isScrollControlled: true, context: context, builder: (BuildContext bc) { return AddBottomSheet( api: api, apiRequest: (url) { ApiRequests.addTorrent(api, url); }, dialogHint: 'Enter Torrent Url', ); }, ); } else { showModalBottomSheet( isScrollControlled: true, context: context, builder: (BuildContext bc) { return AddBottomSheet( apiRequest: (url) async { await ApiRequests.addRSS(api, url); setState(() {}); }, dialogHint: 'Enter Rss Url', ); }, ); }
Same as above
Now the GeneralFeatures -
It is used inside Drawer
'_getAccountsList(api, modeTheme, general)'
This just needs to pass provider of GeneralFeatures, so instead we can just pass provider. No need of Consumer.
'general.filterTileList' and 'general.listOfLabels'
These functions return data which isn't part of a Stream or any automatic change. Provider will work here.
'general.pageController'
This returns a controller defined in GeneralFeatures so it does not need a Consumer.
'general.pageController.jumpToPage(index)'
Same as above
Only the HomePage needs to be inside Consumer of GeneralFeatures because it has TorrentLists which is already inside a Consumer.
The DownloadsPage only needs homeDirectory to get the list of files. No need of Consumer.
RSSFeeds is already inside a Consumer it needs.
RSSFilterDetails just uses - rssFilters = await ApiRequests.getRSSFilters(Provider.of<Api>(context, listen: false));
so it also doesn't needs a Consumer in the tree root.
I tried debugging using a simple print('widget tree updated')
inside the root widget of the main screen and with two providers(Mode and GeneralFeatures) and one Api class inside as it is now in the codebase, the print was being executed multiple times per second which is highly inefficient.
FUN FACT - I tried removing all the three Consumer in the root of the MainScreen and the app was working all fine with all updates in the torrent list, account change, account deletion, list sort, mode change, etc.
from rutorrent-flutter.
Related Issues (20)
- Enhancing documentation by adding Screenshots HOT 3
- Can't login to seedbox HOT 1
- bug: Dark Theme (dev)
- bug: logout from all accounts pushes a new login screen in widget tree (dev)
- Fails to run (Android) HOT 2
- Splash screen appears white even in dark theme HOT 1
- Deprecated Member Use HOT 1
- Mapping Warning while building app HOT 1
- Pubspec dependencies need to be updated HOT 1
- Too many Positional Arguments HOT 1
- Eye icon wrongly executed HOT 4
- Install on Debian HOT 1
- Cannot log in HOT 1
- Edit Save Path HOT 10
- Some target of URI don't exist HOT 3
- Used deprecated FlatButton in the codebase HOT 10
- Issue connecting with Dediseedbox HOT 1
- Issues Found When We ran Flutter unit tests HOT 2
- Issues found when analyzed the project's dart code HOT 7
- Change directory when adding a new torrent
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rutorrent-flutter.