import 'package:intl/intl.dart'; final NumberFormat _euro = NumberFormat.currency(locale: 'fr_FR', symbol: '€'); final DateFormat _dateHeure = DateFormat('d MMM y • HH:mm', 'fr_FR'); String euro(double v) => _euro.format(v); /// Formate un nombre de points de façon lisible : /// entier sans décimale (« 12 pts »), sinon jusqu'à 2 décimales sans zéros /// inutiles (« 0,48 pt », « 2,5 pts »). Gère le singulier/pluriel. String points(double v) { final arrondi = (v * 100).round() / 100; var s = arrondi == arrondi.roundToDouble() ? arrondi.toInt().toString() : arrondi .toStringAsFixed(2) .replaceAll(RegExp(r'0+$'), '') .replaceAll(RegExp(r'\.$'), ''); s = s.replaceAll('.', ','); final abs = arrondi.abs(); final pluriel = abs >= 2 ? 'pts' : 'pt'; return '$s $pluriel'; } /// Comme [points] mais sans le suffixe « pt/pts » (pour les gros affichages). String pointsNombre(double v) { final complet = points(v); return complet.replaceAll(RegExp(r'\s?pts?$'), ''); } String dateHeure(DateTime d) => _dateHeure.format(d);