simplify: dedupe boilerplate and remove dead code across all layers

This commit is contained in:
2026-07-13 22:22:39 +02:00
parent 15791423ea
commit 398b147c76
69 changed files with 345 additions and 651 deletions
@@ -3,6 +3,11 @@ part of '../async_action_button.dart';
typedef AsyncActionCallback = Future<void> Function();
typedef AsyncErrorBuilder = String Function(Object error);
/// Shared style for the inline error message the async-button family renders
/// beneath a control after a caught failure.
TextStyle _asyncErrorTextStyle(BuildContext context) =>
TextStyle(color: Theme.of(context).colorScheme.error, fontSize: 13);
/// Wraps [action] with a try/catch that pops up an [InfoDialog] on failure
/// (using [errorBuilder] or the default error mapper). Returns `true` on
/// success, `false` on caught failure.
@@ -44,10 +44,7 @@ class _AsyncDialogActionState extends State<AsyncDialogAction> {
child: Text(
err,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
fontSize: 13,
),
style: _asyncErrorTextStyle(context),
),
),
Row(
@@ -76,13 +76,7 @@ class _AsyncListTileState extends State<AsyncListTile> {
if (err != null)
Padding(
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 8),
child: Text(
err,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
fontSize: 13,
),
),
child: Text(err, style: _asyncErrorTextStyle(context)),
),
],
);
+1 -4
View File
@@ -108,10 +108,7 @@ class _InlineErrorWrapper extends StatelessWidget {
Text(
err,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).colorScheme.error,
fontSize: 13,
),
style: _asyncErrorTextStyle(context),
),
],
],
-9
View File
@@ -1,4 +1,3 @@
import 'dart:async';
import 'dart:convert';
import 'package:filesize/filesize.dart';
import 'package:flutter/material.dart';
@@ -85,11 +84,3 @@ class _CacheViewState extends State<CacheView> {
),
);
}
extension FutureExtension<T> on Future<T> {
bool isCompleted() {
final completer = Completer<T>();
then(completer.complete).catchError(completer.completeError);
return completer.isCompleted;
}
}
+1 -2
View File
@@ -17,7 +17,6 @@ class FilePick {
static Future<List<String>?> documentPick() async {
final result = await FilePicker.pickFiles(allowMultiple: true);
final paths = result?.files.nonNulls.map((e) => e.path).toList();
return paths?.nonNulls.toList();
return result?.files.map((e) => e.path).nonNulls.toList();
}
}