mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Fixed download speed display.
This commit is contained in:
@@ -15,6 +15,15 @@ class DownloadingPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DownloadingPageState extends State<DownloadingPage> {
|
||||
DownloadTask? firstTask;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
firstTask = LocalManager().downloadingTasks.firstOrNull;
|
||||
firstTask?.addListener(update);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
LocalManager().addListener(update);
|
||||
@@ -24,10 +33,17 @@ class _DownloadingPageState extends State<DownloadingPage> {
|
||||
@override
|
||||
void dispose() {
|
||||
LocalManager().removeListener(update);
|
||||
firstTask?.removeListener(update);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void update() {
|
||||
var currentFirstTask = LocalManager().downloadingTasks.firstOrNull;
|
||||
if (currentFirstTask != firstTask) {
|
||||
firstTask?.removeListener(update);
|
||||
firstTask = currentFirstTask;
|
||||
firstTask?.addListener(update);
|
||||
}
|
||||
if(mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
|
Reference in New Issue
Block a user