download in percentage

This commit is contained in:
Thomas Fransolet 2024-07-07 21:23:24 +02:00
parent d6279fa2e8
commit 96c1694fe2

View File

@ -272,15 +272,18 @@ class _DownloadConfigurationWidgetState extends State<DownloadConfigurationWidge
return ValueListenableBuilder<int>( return ValueListenableBuilder<int>(
valueListenable: currentResourceIndex, valueListenable: currentResourceIndex,
builder: (context, valueIndex, _) { 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( return valueNbr != -1 && valueNbr != 0 ? Center(
child: Padding( child: Padding(
padding: const EdgeInsets.only(bottom: 8.0), padding: const EdgeInsets.only(bottom: 8.0),
child: Text( child: Text(
"${valueIndex.toString()}/${valueNbr.toString()}", '$formattedPercentage%',
style: TextStyle(fontSize: 45, fontWeight: FontWeight.w500), style: const TextStyle(fontSize: 45, fontWeight: FontWeight.w500),
), ),
), ),
) : SizedBox(height: 0,width: 0); ) : const SizedBox(height: 0,width: 0);
} }
); );
} }