Skip to content

Commit

Permalink
Don't set size on DownloadsOverview (fixes overflow on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
jmshrv committed Apr 9, 2021
1 parent 70b5abd commit 42813bd
Showing 1 changed file with 64 additions and 68 deletions.
132 changes: 64 additions & 68 deletions lib/components/DownloadsScreen/DownloadsOverview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,79 +46,75 @@ class _DownloadsOverviewState extends State<DownloadsOverview> {

@override
Widget build(BuildContext context) {
return SizedBox(
height: cardHeight,
child: FutureBuilder<List<DownloadTask>>(
future: FlutterDownloader.loadTasks(),
builder: (context, snapshot) {
if (snapshot.hasData) {
List<DownloadTask> downloadTasks = snapshot.data;
return Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(
text: downloadTasks.length.toString(),
style: TextStyle(fontSize: 48),
),
TextSpan(
text: " downloads",
style:
TextStyle(fontSize: 24, color: Colors.grey),
),
],
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.complete).length} complete",
style: TextStyle(color: Colors.green),
),
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.failed).length} failed",
style: TextStyle(color: Colors.red),
return FutureBuilder<List<DownloadTask>>(
future: FlutterDownloader.loadTasks(),
builder: (context, snapshot) {
if (snapshot.hasData) {
List<DownloadTask> downloadTasks = snapshot.data;
return Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(
text: downloadTasks.length.toString(),
style: TextStyle(fontSize: 48),
),
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.enqueued).length} enqueued",
style: TextStyle(color: Colors.grey),
TextSpan(
text: " downloads",
style: TextStyle(fontSize: 24, color: Colors.grey),
),
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.running).length} running",
style: TextStyle(color: Colors.grey),
),
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.paused).length} paused",
style: TextStyle(color: Colors.grey),
),
DownloadsFileSize(),
],
)
],
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.complete).length} complete",
style: TextStyle(color: Colors.green),
),
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.failed).length} failed",
style: TextStyle(color: Colors.red),
),
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.enqueued).length} enqueued",
style: TextStyle(color: Colors.grey),
),
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.running).length} running",
style: TextStyle(color: Colors.grey),
),
Text(
"${downloadTasks.where((element) => element.status == DownloadTaskStatus.paused).length} paused",
style: TextStyle(color: Colors.grey),
),
DownloadsFileSize(),
],
)
],
),
),
);
} else if (snapshot.hasError) {
errorSnackbar(snapshot.error, context);
return Card(
child: Icon(Icons.error),
);
} else {
return Card(
child: Center(child: CircularProgressIndicator()),
);
}
},
),
),
);
} else if (snapshot.hasError) {
errorSnackbar(snapshot.error, context);
return Card(
child: Icon(Icons.error),
);
} else {
return Card(
child: Center(child: CircularProgressIndicator()),
);
}
},
);
}
}

0 comments on commit 42813bd

Please sign in to comment.