dart format
This commit is contained in:
@@ -8,7 +8,8 @@ import 'dart:async';
|
||||
class CacheInvalidationBus {
|
||||
CacheInvalidationBus._();
|
||||
|
||||
static final StreamController<String> _listFiles = StreamController<String>.broadcast();
|
||||
static final StreamController<String> _listFiles =
|
||||
StreamController<String>.broadcast();
|
||||
|
||||
/// Emits the invalidated `pathString` (in `FilesBloc` format: relative,
|
||||
/// no leading or trailing slash; root is '/').
|
||||
|
||||
@@ -49,7 +49,9 @@ class DownloadJob {
|
||||
final String localPath;
|
||||
final FileDownloader _downloader;
|
||||
|
||||
final ValueNotifier<DownloadStatus> status = ValueNotifier(const DownloadInProgress(0));
|
||||
final ValueNotifier<DownloadStatus> status = ValueNotifier(
|
||||
const DownloadInProgress(0),
|
||||
);
|
||||
bool _disposed = false;
|
||||
|
||||
bool get isFinished =>
|
||||
@@ -86,7 +88,10 @@ class DownloadManager {
|
||||
|
||||
/// Returns the existing job if a download is in progress for [remotePath],
|
||||
/// otherwise starts a new one. Caller listens on [DownloadJob.status].
|
||||
Future<DownloadJob> start({required String remotePath, required String name}) async {
|
||||
Future<DownloadJob> start({
|
||||
required String remotePath,
|
||||
required String name,
|
||||
}) async {
|
||||
final existing = _jobs[remotePath];
|
||||
if (existing != null && !existing.isFinished) return existing;
|
||||
if (existing != null) {
|
||||
|
||||
@@ -28,20 +28,24 @@ class FileDownloader {
|
||||
required void Function() onDone,
|
||||
required void Function(Object error) onError,
|
||||
}) {
|
||||
client.download(
|
||||
url,
|
||||
savePath,
|
||||
cancelToken: _cancelToken,
|
||||
onReceiveProgress: (received, total) {
|
||||
if (_cancelled || total <= 0) return;
|
||||
onProgress((received / total) * 100);
|
||||
},
|
||||
).then((_) {
|
||||
if (_cancelled) return;
|
||||
onDone();
|
||||
}).catchError((Object error) {
|
||||
if (_cancelled) return;
|
||||
onError(error);
|
||||
}).ignore();
|
||||
client
|
||||
.download(
|
||||
url,
|
||||
savePath,
|
||||
cancelToken: _cancelToken,
|
||||
onReceiveProgress: (received, total) {
|
||||
if (_cancelled || total <= 0) return;
|
||||
onProgress((received / total) * 100);
|
||||
},
|
||||
)
|
||||
.then((_) {
|
||||
if (_cancelled) return;
|
||||
onDone();
|
||||
})
|
||||
.catchError((Object error) {
|
||||
if (_cancelled) return;
|
||||
onError(error);
|
||||
})
|
||||
.ignore();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
class UrlOpener {
|
||||
static Future<void> onOpen(LinkableElement link) async {
|
||||
if(await canLaunchUrlString(link.url)) {
|
||||
if (await canLaunchUrlString(link.url)) {
|
||||
await launchUrlString(link.url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user