Skip to content

Commit 3eb0c45

Browse files
committed
Add useIsolates in io directory system
1 parent 292186c commit 3eb0c45

File tree

7 files changed

+81
-67
lines changed

7 files changed

+81
-67
lines changed

packages/lw_file_system/lib/src/api/base/directory.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ abstract class DirectoryFileSystem extends GeneralFileSystem
257257
factory DirectoryFileSystem.fromPlatform(
258258
FileSystemConfig config, {
259259
final ExternalStorage? storage,
260+
bool useIsolates = false,
260261
CreateDefaultCallback<DirectoryFileSystem> createDefault =
261262
defaultCreateDefault,
262263
}) {
@@ -276,10 +277,12 @@ abstract class DirectoryFileSystem extends GeneralFileSystem
276277
config: config,
277278
storage: e,
278279
createDefault: createDefault,
280+
useIsolates: useIsolates,
279281
),
280282
_ => IODirectoryFileSystem(
281283
config: config,
282284
createDefault: createDefault,
285+
useIsolates: useIsolates,
283286
),
284287
};
285288
}

packages/lw_file_system/lib/src/api/file_system_io.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import 'package:path/path.dart' as p;
88
class IODirectoryFileSystem extends DirectoryFileSystem {
99
@override
1010
final LocalStorage? storage;
11+
final bool useIsolates;
1112

1213
IODirectoryFileSystem({
1314
this.storage,
1415
required super.config,
1516
super.createDefault,
17+
this.useIsolates = false,
1618
});
1719

1820
String get remoteName => storage?.identifier ?? '';
@@ -84,11 +86,20 @@ class IODirectoryFileSystem extends DirectoryFileSystem {
8486
bool forceSync = false,
8587
}) async {
8688
path = normalizePath(path);
87-
final file = File(await getAbsolutePath(path));
89+
path = await getAbsolutePath(path);
90+
if (useIsolates) {
91+
await compute(_updateFile, (path, data));
92+
} else {
93+
await _updateFile((path, data));
94+
}
95+
}
96+
97+
Future<void> _updateFile((String, Uint8List) e) async {
98+
final file = File(e.$1);
8899
if (!await file.exists()) {
89100
await file.create(recursive: true);
90101
}
91-
await file.writeAsBytes(data);
102+
await file.writeAsBytes(e.$2);
92103
}
93104

94105
@override

packages/lw_file_system/lib/src/api/typed.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class TypedDirectoryFileSystem<T> extends TypedFileSystem<T>
5252
factory TypedDirectoryFileSystem.build(
5353
FileSystemConfig config, {
5454
ExternalStorage? storage,
55+
bool useIsolates = false,
5556
CreateDefaultCallback<TypedDirectoryFileSystem<T>> createDefault =
5657
defaultCreateDefault,
5758
required EncodeTypedFileSystemCallback<T> onEncode,
@@ -64,6 +65,7 @@ class TypedDirectoryFileSystem<T> extends TypedFileSystem<T>
6465
config,
6566
storage: storage,
6667
createDefault: createWrappedDefault,
68+
useIsolates: useIsolates,
6769
);
6870
fileSystem = TypedDirectoryFileSystem._(
6971
directorySystem,

packages/lw_sysapi/example/pubspec.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ packages:
117117
dependency: transitive
118118
description:
119119
name: file_selector_macos
120-
sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc"
120+
sha256: "8c9250b2bd2d8d4268e39c82543bacbaca0fda7d29e0728c3c4bbb7c820fd711"
121121
url: "https://pub.dev"
122122
source: hosted
123-
version: "0.9.4+2"
123+
version: "0.9.4+3"
124124
file_selector_platform_interface:
125125
dependency: transitive
126126
description:
@@ -180,10 +180,10 @@ packages:
180180
dependency: transitive
181181
description:
182182
name: http
183-
sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f
183+
sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b"
184184
url: "https://pub.dev"
185185
source: hosted
186-
version: "1.3.0"
186+
version: "1.4.0"
187187
http_parser:
188188
dependency: transitive
189189
description:
@@ -488,10 +488,10 @@ packages:
488488
dependency: transitive
489489
description:
490490
name: win32
491-
sha256: dc6ecaa00a7c708e5b4d10ee7bec8c270e9276dfcab1783f57e9962d7884305f
491+
sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
492492
url: "https://pub.dev"
493493
source: hosted
494-
version: "5.12.0"
494+
version: "5.14.0"
495495
xdg_directories:
496496
dependency: transitive
497497
description:

packages/material_leap/example/pubspec.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ packages:
55
dependency: transitive
66
description:
77
name: archive
8-
sha256: "0c64e928dcbefddecd234205422bcfc2b5e6d31be0b86fef0d0dd48d7b4c9742"
8+
sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd"
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "4.0.4"
11+
version: "4.0.7"
1212
async:
1313
dependency: transitive
1414
description:
@@ -78,10 +78,10 @@ packages:
7878
dependency: transitive
7979
description:
8080
name: dart_mappable
81-
sha256: "2255b2c00e328a65fef5a8df2dabfc0dc9c2e518c33a50051a4519b1c7a28c48"
81+
sha256: "15f41a35da8ee690bbfa0059fa241edeeaea73f89a2ba685b354ece07cd8ada6"
8282
url: "https://pub.dev"
8383
source: hosted
84-
version: "4.5.0"
84+
version: "4.6.0"
8585
fake_async:
8686
dependency: transitive
8787
description:
@@ -107,10 +107,10 @@ packages:
107107
dependency: transitive
108108
description:
109109
name: flutter_bloc
110-
sha256: "1046d719fbdf230330d3443187cc33cc11963d15c9089f6cc56faa42a4c5f0cc"
110+
sha256: cf51747952201a455a1c840f8171d273be009b932c75093020f9af64f2123e38
111111
url: "https://pub.dev"
112112
source: hosted
113-
version: "9.1.0"
113+
version: "9.1.1"
114114
flutter_lints:
115115
dependency: "direct dev"
116116
description:
@@ -253,18 +253,18 @@ packages:
253253
dependency: transitive
254254
description:
255255
name: posix
256-
sha256: a0117dc2167805aa9125b82eee515cc891819bac2f538c83646d355b16f58b9a
256+
sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61"
257257
url: "https://pub.dev"
258258
source: hosted
259-
version: "6.0.1"
259+
version: "6.0.3"
260260
provider:
261261
dependency: transitive
262262
description:
263263
name: provider
264-
sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
264+
sha256: "4abbd070a04e9ddc287673bf5a030c7ca8b685ff70218720abab8b092f53dd84"
265265
url: "https://pub.dev"
266266
source: hosted
267-
version: "6.1.2"
267+
version: "6.1.5"
268268
screen_retriever:
269269
dependency: transitive
270270
description:
@@ -402,10 +402,10 @@ packages:
402402
dependency: transitive
403403
description:
404404
name: window_manager
405-
sha256: "732896e1416297c63c9e3fb95aea72d0355f61390263982a47fd519169dc5059"
405+
sha256: "7eb6d6c4164ec08e1bf978d6e733f3cebe792e2a23fb07cbca25c2872bfdbdcd"
406406
url: "https://pub.dev"
407407
source: hosted
408-
version: "0.4.3"
408+
version: "0.5.1"
409409
sdks:
410410
dart: ">=3.8.0 <4.0.0"
411411
flutter: ">=3.18.0-18.0.pre.54"

packages/material_leap/lib/l10n/leap_localizations.dart

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ import 'leap_localizations_zh.dart';
8989
/// property.
9090
abstract class LeapLocalizations {
9191
LeapLocalizations(String locale)
92-
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
92+
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
9393

9494
final String localeName;
9595

@@ -112,11 +112,11 @@ abstract class LeapLocalizations {
112112
/// of delegates is preferred or required.
113113
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
114114
<LocalizationsDelegate<dynamic>>[
115-
delegate,
116-
GlobalMaterialLocalizations.delegate,
117-
GlobalCupertinoLocalizations.delegate,
118-
GlobalWidgetsLocalizations.delegate,
119-
];
115+
delegate,
116+
GlobalMaterialLocalizations.delegate,
117+
GlobalCupertinoLocalizations.delegate,
118+
GlobalWidgetsLocalizations.delegate,
119+
];
120120

121121
/// A list of this localizations delegate's supported locales.
122122
static const List<Locale> supportedLocales = <Locale>[
@@ -149,7 +149,7 @@ abstract class LeapLocalizations {
149149
Locale('uk'),
150150
Locale('vi'),
151151
Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant'),
152-
Locale('zh'),
152+
Locale('zh')
153153
];
154154

155155
/// No description provided for @color.
@@ -280,41 +280,40 @@ class _LeapLocalizationsDelegate
280280
@override
281281
Future<LeapLocalizations> load(Locale locale) {
282282
return SynchronousFuture<LeapLocalizations>(
283-
lookupLeapLocalizations(locale),
284-
);
283+
lookupLeapLocalizations(locale));
285284
}
286285

287286
@override
288287
bool isSupported(Locale locale) => <String>[
289-
'af',
290-
'ar',
291-
'ca',
292-
'cs',
293-
'da',
294-
'de',
295-
'el',
296-
'en',
297-
'es',
298-
'fi',
299-
'fr',
300-
'he',
301-
'hu',
302-
'it',
303-
'ja',
304-
'ko',
305-
'nl',
306-
'no',
307-
'pl',
308-
'pt',
309-
'ro',
310-
'ru',
311-
'sr',
312-
'sv',
313-
'tr',
314-
'uk',
315-
'vi',
316-
'zh',
317-
].contains(locale.languageCode);
288+
'af',
289+
'ar',
290+
'ca',
291+
'cs',
292+
'da',
293+
'de',
294+
'el',
295+
'en',
296+
'es',
297+
'fi',
298+
'fr',
299+
'he',
300+
'hu',
301+
'it',
302+
'ja',
303+
'ko',
304+
'nl',
305+
'no',
306+
'pl',
307+
'pt',
308+
'ro',
309+
'ru',
310+
'sr',
311+
'sv',
312+
'tr',
313+
'uk',
314+
'vi',
315+
'zh'
316+
].contains(locale.languageCode);
318317

319318
@override
320319
bool shouldReload(_LeapLocalizationsDelegate old) => false;
@@ -406,9 +405,8 @@ LeapLocalizations lookupLeapLocalizations(Locale locale) {
406405
}
407406

408407
throw FlutterError(
409-
'LeapLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
410-
'an issue with the localizations generation tool. Please file an issue '
411-
'on GitHub with a reproducible sample app and the gen-l10n configuration '
412-
'that was used.',
413-
);
408+
'LeapLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
409+
'an issue with the localizations generation tool. Please file an issue '
410+
'on GitHub with a reproducible sample app and the gen-l10n configuration '
411+
'that was used.');
414412
}

tools/app_tools/pubspec.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ packages:
55
dependency: "direct main"
66
description:
77
name: args
8-
sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6
8+
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "2.6.0"
11+
version: "2.7.0"
1212
clock:
1313
dependency: transitive
1414
description:
@@ -45,10 +45,10 @@ packages:
4545
dependency: transitive
4646
description:
4747
name: meta
48-
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
48+
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
4949
url: "https://pub.dev"
5050
source: hosted
51-
version: "1.16.0"
51+
version: "1.17.0"
5252
path:
5353
dependency: transitive
5454
description:

0 commit comments

Comments
 (0)