Skip to content

Commit e2eb052

Browse files
gitubpatriceclaude
andcommitted
chore: dart format + reformatage trailing commas
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f97ffa2 commit e2eb052

5 files changed

Lines changed: 77 additions & 52 deletions

File tree

.githooks/pre-commit

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ if ! flutter analyze --no-fatal-infos 2>&1 | tail -20; then
2828
fi
2929

3030
echo "${YLW}→ dart format check...${RST}"
31-
UNFORMATTED=$(dart format --output=none --set-exit-if-changed $STAGED_DART 2>&1 | grep -v "^$" || true)
32-
if [ -n "$UNFORMATTED" ]; then
33-
echo "${RED}✗ Fichiers non formatés :${RST}"
34-
echo "$UNFORMATTED"
35-
echo ""
36-
echo "${YLW}→ Lance : dart format <fichier> et re-stage avant commit${RST}"
37-
exit 1
31+
# `--set-exit-if-changed` retourne 1 si des changements seraient appliqués.
32+
# On capture seulement les fichiers nommément "Changed" (pas le résumé final
33+
# "Formatted N files (0 changed)" qui n'indique aucun changement).
34+
if ! dart format --output=none --set-exit-if-changed $STAGED_DART > /tmp/dart_fmt_out.txt 2>&1; then
35+
CHANGED=$(grep '^Changed ' /tmp/dart_fmt_out.txt || true)
36+
if [ -n "$CHANGED" ]; then
37+
echo "${RED}✗ Fichiers non formatés :${RST}"
38+
echo "$CHANGED"
39+
echo ""
40+
echo "${YLW}→ Lance : dart format <fichier> et re-stage avant commit${RST}"
41+
exit 1
42+
fi
3843
fi
3944

4045
echo "${GRN}✓ Pre-commit OK${RST}"

lib/src/recents/recent_file.dart

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ class RecentFile {
2121
});
2222

2323
RecentFile copyWith({bool? isFavorite}) => RecentFile(
24-
path: path,
25-
name: name,
26-
lastOpened: lastOpened,
27-
sizeBytes: sizeBytes,
28-
isFavorite: isFavorite ?? this.isFavorite,
29-
);
24+
path: path,
25+
name: name,
26+
lastOpened: lastOpened,
27+
sizeBytes: sizeBytes,
28+
isFavorite: isFavorite ?? this.isFavorite,
29+
);
3030

3131
/// Extension du fichier (sans le point), en minuscules. Vide si pas de point.
3232
/// Exemple : `RecentFile(name: 'Foo.PDF').extension == 'pdf'`.
3333
String get extension =>
3434
name.contains('.') ? name.split('.').last.toLowerCase() : '';
3535

3636
Map<String, dynamic> toJson() => {
37-
'path': path,
38-
'name': name,
39-
'lastOpened': lastOpened.toIso8601String(),
40-
'sizeBytes': sizeBytes,
41-
'isFavorite': isFavorite,
42-
};
37+
'path': path,
38+
'name': name,
39+
'lastOpened': lastOpened.toIso8601String(),
40+
'sizeBytes': sizeBytes,
41+
'isFavorite': isFavorite,
42+
};
4343

4444
/// Parse défensif : tout champ manquant ou de mauvais type lève
4545
/// [FormatException] (au lieu d'un `TypeError` cryptique). Le service
@@ -49,7 +49,7 @@ class RecentFile {
4949
factory RecentFile.fromJson(Map<String, dynamic> json) {
5050
final path = json['path'];
5151
final name = json['name'];
52-
final iso = json['lastOpened'];
52+
final iso = json['lastOpened'];
5353
final size = json['sizeBytes'];
5454
if (path is! String || path.isEmpty) {
5555
throw const FormatException('RecentFile JSON invalide : path');
@@ -67,7 +67,9 @@ class RecentFile {
6767
try {
6868
lastOpened = DateTime.parse(iso);
6969
} catch (_) {
70-
throw const FormatException('RecentFile JSON invalide : lastOpened format');
70+
throw const FormatException(
71+
'RecentFile JSON invalide : lastOpened format',
72+
);
7173
}
7274
return RecentFile(
7375
path: path,

lib/src/recents/recent_files_service.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ class RecentFilesService {
1818
/// Nombre maximum d'entrées conservées (les plus anciennes sont éjectées).
1919
final int maxFiles;
2020

21-
const RecentFilesService({
22-
this.key = 'recent_files',
23-
this.maxFiles = 20,
24-
});
21+
const RecentFilesService({this.key = 'recent_files', this.maxFiles = 20});
2522

2623
/// Charge la liste persistée, filtre les fichiers disparus + entrées
2724
/// corrompues, trie par date décroissante.
@@ -50,7 +47,9 @@ class RecentFilesService {
5047
/// `isFavorite` existant. Refuse silencieusement les paths invalides
5148
/// (basename `..`, séparateur, NUL).
5249
Future<List<RecentFile>> addOrUpdate(
53-
List<RecentFile> current, String path) async {
50+
List<RecentFile> current,
51+
String path,
52+
) async {
5453
final file = File(path);
5554
if (!await file.exists()) return current;
5655
final String name;
@@ -60,7 +59,9 @@ class RecentFilesService {
6059
return current;
6160
}
6261
final size = await file.length();
63-
final existing = current.where((f) => f.path == path).cast<RecentFile?>()
62+
final existing = current
63+
.where((f) => f.path == path)
64+
.cast<RecentFile?>()
6465
.firstWhere((_) => true, orElse: () => null);
6566
final isFav = existing?.isFavorite ?? false;
6667
final updated = [
@@ -78,15 +79,16 @@ class RecentFilesService {
7879
return trimmed;
7980
}
8081

81-
Future<List<RecentFile>> remove(
82-
List<RecentFile> current, String path) async {
82+
Future<List<RecentFile>> remove(List<RecentFile> current, String path) async {
8383
final updated = current.where((f) => f.path != path).toList();
8484
await _save(updated);
8585
return updated;
8686
}
8787

8888
Future<List<RecentFile>> toggleFavorite(
89-
List<RecentFile> current, String path) async {
89+
List<RecentFile> current,
90+
String path,
91+
) async {
9092
final updated = current
9193
.map((f) => f.path == path ? f.copyWith(isFavorite: !f.isFavorite) : f)
9294
.toList();

lib/src/share/cloud_share_row.dart

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import 'package:share_plus/share_plus.dart';
55
/// Identifiants des packages Android pour les destinations cloud
66
/// supportées par Files Tech.
77
class CloudTargets {
8-
static const kDrive = 'com.infomaniak.drive';
8+
static const kDrive = 'com.infomaniak.drive';
99
static const googleDrive = 'com.google.android.apps.docs';
1010
static const protonDrive = 'me.proton.android.drive';
1111

1212
/// Cible cross-app : ouvre un PDF directement dans PDF Tech depuis RFT.
1313
/// Utilisé par RFT (file_explorer) — pas de cible inverse pour le moment.
14-
static const pdfTech = 'com.pdftech.pdf_tech';
14+
static const pdfTech = 'com.pdftech.pdf_tech';
1515
}
1616

1717
/// Rangée de boutons d'envoi cloud direct + partage générique.
@@ -65,21 +65,25 @@ class CloudShareRow extends StatelessWidget {
6565
'package': pkg,
6666
});
6767
} on PlatformException catch (e) {
68-
messenger.showSnackBar(SnackBar(
69-
content: Text(e.code == 'NOT_INSTALLED'
70-
? '$label n\'est pas installé sur cet appareil.'
71-
: 'Erreur d\'envoi vers $label.'),
72-
));
68+
messenger.showSnackBar(
69+
SnackBar(
70+
content: Text(
71+
e.code == 'NOT_INSTALLED'
72+
? '$label n\'est pas installé sur cet appareil.'
73+
: 'Erreur d\'envoi vers $label.',
74+
),
75+
),
76+
);
7377
} on MissingPluginException {
7478
// Channel non enregistré côté Kotlin — typiquement en hot-reload sur un
7579
// build qui ne contient pas encore le handler. Évite le crash.
76-
messenger.showSnackBar(SnackBar(
77-
content: Text('Service indisponible pour $label.'),
78-
));
80+
messenger.showSnackBar(
81+
SnackBar(content: Text('Service indisponible pour $label.')),
82+
);
7983
} catch (_) {
80-
messenger.showSnackBar(SnackBar(
81-
content: Text('Erreur d\'envoi vers $label.'),
82-
));
84+
messenger.showSnackBar(
85+
SnackBar(content: Text('Erreur d\'envoi vers $label.')),
86+
);
8387
}
8488
}
8589

@@ -97,20 +101,31 @@ class CloudShareRow extends StatelessWidget {
97101
),
98102
OutlinedButton.icon(
99103
onPressed: () => _send(context, CloudTargets.kDrive, 'kDrive'),
100-
icon: const Icon(Icons.cloud_upload_outlined,
101-
size: 14, color: Color(0xFF0098FF)),
104+
icon: const Icon(
105+
Icons.cloud_upload_outlined,
106+
size: 14,
107+
color: Color(0xFF0098FF),
108+
),
102109
label: const Text('kDrive', style: TextStyle(fontSize: 12)),
103110
),
104111
OutlinedButton.icon(
105-
onPressed: () => _send(context, CloudTargets.googleDrive, 'Google Drive'),
106-
icon: const Icon(Icons.cloud_upload_outlined,
107-
size: 14, color: Color(0xFFEA4335)),
112+
onPressed: () =>
113+
_send(context, CloudTargets.googleDrive, 'Google Drive'),
114+
icon: const Icon(
115+
Icons.cloud_upload_outlined,
116+
size: 14,
117+
color: Color(0xFFEA4335),
118+
),
108119
label: const Text('Google Drive', style: TextStyle(fontSize: 12)),
109120
),
110121
OutlinedButton.icon(
111-
onPressed: () => _send(context, CloudTargets.protonDrive, 'Proton Drive'),
112-
icon: const Icon(Icons.cloud_upload_outlined,
113-
size: 14, color: Color(0xFF6D4AFF)),
122+
onPressed: () =>
123+
_send(context, CloudTargets.protonDrive, 'Proton Drive'),
124+
icon: const Icon(
125+
Icons.cloud_upload_outlined,
126+
size: 14,
127+
color: Color(0xFF6D4AFF),
128+
),
114129
label: const Text('Proton Drive', style: TextStyle(fontSize: 12)),
115130
),
116131
],

lib/src/update/update_service.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class UpdateService {
8585
if (!force && now - last < cacheDuration.inMilliseconds) return null;
8686

8787
final uri = Uri.parse(
88-
'https://api.github.com/repos/$owner/$repo/releases/latest');
88+
'https://api.github.com/repos/$owner/$repo/releases/latest',
89+
);
8990
final response = await http
9091
.get(uri, headers: {'Accept': 'application/vnd.github+json'})
9192
.timeout(const Duration(seconds: 10));

0 commit comments

Comments
 (0)