@@ -12,25 +12,13 @@ void initFileSystemThread() {
1212 init_io_thread ();
1313}
1414
15- enum OperationStatus {
16- pending,
17- running,
18- cancellationPending,
19- cancelled,
20- error,
21- complete,
22- }
15+ enum OperationStatus { pending, running, cancellationPending, cancelled, error, complete }
2316
2417class Cancellable extends ChangeNotifier {
2518 Cancellable () {
26- _cancelCallable = NativeCallable <Void Function ()>.isolateLocal (
27- notifyListeners,
28- );
19+ _cancelCallable = NativeCallable <Void Function ()>.isolateLocal (notifyListeners);
2920 _handle = cancellable_new ();
30- _cancelCallbackHandlerId = cancellable_connect (
31- _handle,
32- _cancelCallable.nativeFunction,
33- );
21+ _cancelCallbackHandlerId = cancellable_connect (_handle, _cancelCallable.nativeFunction);
3422 }
3523
3624 late final Pointer <GCancellable > _handle;
@@ -60,9 +48,7 @@ abstract class BaseFileSystemOperation<Res> {
6048 _start ();
6149 }
6250
63- final ValueNotifier <OperationStatus > _status = ValueNotifier (
64- OperationStatus .pending,
65- );
51+ final ValueNotifier <OperationStatus > _status = ValueNotifier (OperationStatus .pending);
6652 final Completer <Res > _completer = Completer ();
6753 late final Cancellable _cancellable;
6854 late final bool _implicitCancellable;
@@ -82,11 +68,7 @@ abstract class BaseFileSystemOperation<Res> {
8268 final domain = error_domain_name (_error.value).cast <Utf8 >().toDartString ();
8369 final message = _error.value.ref.message.cast <Utf8 >().toDartString ();
8470
85- return NativeException ._(
86- domain: domain,
87- code: _error.value.ref.code,
88- message: message,
89- );
71+ return NativeException ._(domain: domain, code: _error.value.ref.code, message: message);
9072 }
9173
9274 void _create () {
@@ -128,8 +110,7 @@ abstract class BaseFileSystemOperation<Res> {
128110 }
129111}
130112
131- typedef _CallableCreateCallback <T > =
132- NativeCallable Function (void Function (T ) onComplete);
113+ typedef _CallableCreateCallback <T > = NativeCallable Function (void Function (T ) onComplete);
133114typedef _StartOperationCallback =
134115 void Function (
135116 Pointer <GCancellable > cancellable,
@@ -155,11 +136,7 @@ class FileSystemOperation<Res> extends BaseFileSystemOperation<Res> {
155136
156137 @override
157138 void _start () {
158- _onStartOperation (
159- _cancellable._handle,
160- _completeCallable.nativeFunction,
161- _error,
162- );
139+ _onStartOperation (_cancellable._handle, _completeCallable.nativeFunction, _error);
163140 }
164141
165142 @override
@@ -223,12 +200,8 @@ class TransferFileOperation extends BaseFileSystemOperation<bool> {
223200 @override
224201 void _create () {
225202 super ._create ();
226- _progressCallable = NativeCallable <Void Function (Long , Long )>.listener (
227- _onProgress,
228- );
229- _completeCallable = NativeCallable <Void Function (Bool )>.listener (
230- _onComplete,
231- );
203+ _progressCallable = NativeCallable <Void Function (Long , Long )>.listener (_onProgress);
204+ _completeCallable = NativeCallable <Void Function (Bool )>.listener (_onComplete);
232205 }
233206
234207 @override
@@ -318,15 +291,14 @@ class File implements Finalizable {
318291 NativeCallable <Void Function (Pointer <GFileEnumerator >)>.listener (
319292 (Pointer <GFileEnumerator > v) => onComplete (FileEnumerator ._(v)),
320293 ),
321- onStartOperation: (cancellable, onComplete, error) =>
322- file_enumerate_children (
323- _handle,
324- attributes.toNativeUtf8 ().cast (),
325- 0 ,
326- cancellable,
327- onComplete.cast (),
328- error,
329- ),
294+ onStartOperation: (cancellable, onComplete, error) => file_enumerate_children (
295+ _handle,
296+ attributes.toNativeUtf8 ().cast (),
297+ 0 ,
298+ cancellable,
299+ onComplete.cast (),
300+ error,
301+ ),
330302 cancellable: cancellable,
331303 );
332304 }
@@ -345,10 +317,7 @@ class File implements Finalizable {
345317 );
346318 }
347319
348- FileSystemOperation <FileInfo > queryInfo ({
349- String attributes = '*' ,
350- Cancellable ? cancellable,
351- }) {
320+ FileSystemOperation <FileInfo > queryInfo ({String attributes = '*' , Cancellable ? cancellable}) {
352321 return FileSystemOperation <FileInfo >._(
353322 target: _handle.cast (),
354323 onCreateCompleteCallable: (onComplete) =>
@@ -436,10 +405,7 @@ class FileInfo implements Finalizable {
436405
437406 List <String >? listAttributes ({String ? namespace}) {
438407 final namespacePtr = namespace? .toNativeUtf8 ();
439- final attributes = fileinfo_list_attributes (
440- _handle,
441- namespacePtr? .cast () ?? nullptr,
442- );
408+ final attributes = fileinfo_list_attributes (_handle, namespacePtr? .cast () ?? nullptr);
443409
444410 if (namespacePtr != null ) calloc.free (namespacePtr);
445411 if (attributes == nullptr) return null ;
@@ -472,24 +438,15 @@ extension type FileList._(Pointer<GList> _handle) {
472438}
473439
474440extension type FileEnumerator ._(Pointer <GFileEnumerator > _handle) {
475- FileSystemOperation <FileList ?> enumerate ({
476- int fileAmount = 4 ,
477- Cancellable ? cancellable,
478- }) {
441+ FileSystemOperation <FileList ?> enumerate ({int fileAmount = 4 , Cancellable ? cancellable}) {
479442 return FileSystemOperation <FileList ?>._(
480443 target: _handle.cast (),
481444 onCreateCompleteCallable: (onComplete) =>
482445 NativeCallable <Void Function (Pointer <GList >)>.listener (
483- (Pointer <GList > v) =>
484- onComplete (v != nullptr ? FileList ._(v) : null ),
446+ (Pointer <GList > v) => onComplete (v != nullptr ? FileList ._(v) : null ),
485447 ),
486- onStartOperation: (cancellable, onComplete, error) => fileenum_next_files (
487- _handle,
488- fileAmount,
489- cancellable,
490- onComplete.cast (),
491- error,
492- ),
448+ onStartOperation: (cancellable, onComplete, error) =>
449+ fileenum_next_files (_handle, fileAmount, cancellable, onComplete.cast (), error),
493450 cancellable: cancellable,
494451 );
495452 }
@@ -517,11 +474,7 @@ class NativeException implements Exception {
517474 final int code;
518475 final String message;
519476
520- const NativeException ._({
521- required this .domain,
522- required this .code,
523- required this .message,
524- });
477+ const NativeException ._({required this .domain, required this .code, required this .message});
525478
526479 @override
527480 String toString () {
0 commit comments