From 96c1694fe2bf821fb55464f93c7b727c56c5c791 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Sun, 7 Jul 2024 21:23:24 +0200 Subject: [PATCH] download in percentage --- lib/Services/downloadConfiguration.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Services/downloadConfiguration.dart b/lib/Services/downloadConfiguration.dart index 1ac90cd..03bf47f 100644 --- a/lib/Services/downloadConfiguration.dart +++ b/lib/Services/downloadConfiguration.dart @@ -272,15 +272,18 @@ class _DownloadConfigurationWidgetState extends State( valueListenable: currentResourceIndex, builder: (context, valueIndex, _) { + var valueInPercentage = valueNbr > 0 ? (valueIndex / valueNbr) * 100 : 100; + String formattedPercentage = valueInPercentage.toStringAsFixed(0); // Limite à 2 décimales + return valueNbr != -1 && valueNbr != 0 ? Center( child: Padding( padding: const EdgeInsets.only(bottom: 8.0), child: Text( - "${valueIndex.toString()}/${valueNbr.toString()}", - style: TextStyle(fontSize: 45, fontWeight: FontWeight.w500), + '$formattedPercentage%', + style: const TextStyle(fontSize: 45, fontWeight: FontWeight.w500), ), ), - ) : SizedBox(height: 0,width: 0); + ) : const SizedBox(height: 0,width: 0); } ); }