simplify: dedupe boilerplate and remove dead code across all layers
This commit is contained in:
@@ -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)),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user