@@ -27,7 +27,7 @@ void main() {
27
27
test ('saves and reads binary data successfully' , () async {
28
28
const filePath = 'test_file' ;
29
29
final data = Uint8List .fromList ([1 , 2 , 3 , 4 , 5 ]);
30
- final size = await storage.saveFile (filePath, data);
30
+ final size = await storage.saveFile (filePath, Stream . value ( data) );
31
31
expect (size, equals (data.length));
32
32
33
33
final resultStream = storage.readFile (filePath);
@@ -56,7 +56,7 @@ void main() {
56
56
57
57
expect (await nonExistentDir.exists (), isFalse);
58
58
59
- final size = await storage.saveFile (filePath, data);
59
+ final size = await storage.saveFile (filePath, Stream . value ( data) );
60
60
expect (size, equals (data.length));
61
61
expect (await nonExistentDir.exists (), isTrue);
62
62
@@ -77,7 +77,7 @@ void main() {
77
77
78
78
expect (await nestedDir.exists (), isFalse);
79
79
80
- final size = await storage.saveFile (filePath, data);
80
+ final size = await storage.saveFile (filePath, Stream . value ( data) );
81
81
expect (size, equals (data.length));
82
82
expect (await nestedDir.exists (), isTrue);
83
83
@@ -96,8 +96,8 @@ void main() {
96
96
final originalData = Uint8List .fromList ([1 , 2 , 3 ]);
97
97
final newData = Uint8List .fromList ([4 , 5 , 6 , 7 ]);
98
98
99
- await storage.saveFile (filePath, originalData);
100
- final size = await storage.saveFile (filePath, newData);
99
+ await storage.saveFile (filePath, Stream . value ( originalData) );
100
+ final size = await storage.saveFile (filePath, Stream . value ( newData) );
101
101
expect (size, equals (newData.length));
102
102
103
103
final resultStream = storage.readFile (filePath);
@@ -113,9 +113,8 @@ void main() {
113
113
test ('saveFile with empty data writes empty file and returns 0 size' ,
114
114
() async {
115
115
const filePath = 'empty_file' ;
116
- final emptyBytes = Uint8List (0 );
117
116
118
- final size = await storage.saveFile (filePath, emptyBytes );
117
+ final size = await storage.saveFile (filePath, Stream . empty () );
119
118
expect (size, 0 );
120
119
121
120
final resultStream = storage.readFile (filePath);
@@ -136,7 +135,7 @@ void main() {
136
135
];
137
136
final expectedBytes =
138
137
Uint8List .fromList (chunks.expand ((c) => c).toList ());
139
- await storage.saveFile (filePath, expectedBytes);
138
+ await storage.saveFile (filePath, Stream . value ( expectedBytes) );
140
139
141
140
final outChunks = await storage.readFile (filePath).toList ();
142
141
final outBytes = Uint8List .fromList (
@@ -147,7 +146,7 @@ void main() {
147
146
148
147
test ('fileExists becomes false after deleteFile' , () async {
149
148
const filePath = 'exists_then_delete' ;
150
- await storage.saveFile (filePath, Uint8List .fromList ([1 ]));
149
+ await storage.saveFile (filePath, Stream . value ( Uint8List .fromList ([1 ]) ));
151
150
expect (await storage.fileExists (filePath), isTrue);
152
151
await storage.deleteFile (filePath);
153
152
expect (await storage.fileExists (filePath), isFalse);
@@ -159,7 +158,7 @@ void main() {
159
158
160
159
// Create a file, then re-initialize again
161
160
const filePath = 'idempotent_test' ;
162
- await storage.saveFile (filePath, Uint8List .fromList ([9 ]));
161
+ await storage.saveFile (filePath, Stream . value ( Uint8List .fromList ([9 ]) ));
163
162
await storage.initialize ();
164
163
165
164
// File should still exist (initialize should not clear data)
@@ -184,7 +183,7 @@ void main() {
184
183
test ('supports unicode and emoji filenames' , () async {
185
184
const filePath = '測試_файл_📷.bin' ;
186
185
final bytes = Uint8List .fromList ([10 , 20 , 30 , 40 ]);
187
- await storage.saveFile (filePath, bytes);
186
+ await storage.saveFile (filePath, Stream . value ( bytes) );
188
187
189
188
final out = await storage.readFile (filePath).toList ();
190
189
expect (out, equals ([bytes]));
@@ -196,7 +195,7 @@ void main() {
196
195
() async {
197
196
const filePath = 'with_media_type' ;
198
197
final data = Uint8List .fromList ([1 , 2 , 3 ]);
199
- await storage.saveFile (filePath, data);
198
+ await storage.saveFile (filePath, Stream . value ( data) );
200
199
201
200
final result =
202
201
await storage.readFile (filePath, mediaType: 'image/jpeg' ).toList ();
@@ -209,7 +208,7 @@ void main() {
209
208
const filePath = 'delete_test' ;
210
209
final data = Uint8List .fromList ([1 , 2 , 3 ]);
211
210
212
- await storage.saveFile (filePath, data);
211
+ await storage.saveFile (filePath, Stream . value ( data) );
213
212
expect (await storage.fileExists (filePath), isTrue);
214
213
215
214
await storage.deleteFile (filePath);
@@ -258,7 +257,7 @@ void main() {
258
257
const filePath = 'exists_test' ;
259
258
final data = Uint8List .fromList ([1 , 2 , 3 ]);
260
259
261
- await storage.saveFile (filePath, data);
260
+ await storage.saveFile (filePath, Stream . value ( data) );
262
261
expect (await storage.fileExists (filePath), isTrue);
263
262
264
263
await d.file (filePath, data).validate ();
@@ -276,7 +275,7 @@ void main() {
276
275
const filePath = 'file with spaces & symbols!@#' ;
277
276
final data = Uint8List .fromList ([1 , 2 , 3 ]);
278
277
279
- final size = await storage.saveFile (filePath, data);
278
+ final size = await storage.saveFile (filePath, Stream . value ( data) );
280
279
expect (size, equals (data.length));
281
280
282
281
final resultStream = storage.readFile (filePath);
@@ -301,7 +300,7 @@ void main() {
301
300
),
302
301
);
303
302
}
304
- final size = await storage.saveFile (filePath, data);
303
+ final size = await storage.saveFile (filePath, Stream . value ( data) );
305
304
expect (size, equals (data.length));
306
305
307
306
final resultStream = storage.readFile (filePath);
@@ -321,7 +320,7 @@ void main() {
321
320
322
321
for (int i = 0 ; i < fileCount; i++ ) {
323
322
final data = Uint8List .fromList ([i, i + 1 , i + 2 ]);
324
- futures.add (storage.saveFile ('file_$i ' , data));
323
+ futures.add (storage.saveFile ('file_$i ' , Stream . value ( data) ));
325
324
}
326
325
327
326
await Future .wait (futures);
@@ -346,8 +345,8 @@ void main() {
346
345
final data1 = Uint8List .fromList ([1 , 2 , 3 ]);
347
346
final data2 = Uint8List .fromList ([4 , 5 , 6 ]);
348
347
final futures = [
349
- storage.saveFile (filePath, data1),
350
- storage.saveFile (filePath, data2),
348
+ storage.saveFile (filePath, Stream . value ( data1) ),
349
+ storage.saveFile (filePath, Stream . value ( data2) ),
351
350
];
352
351
353
352
await Future .wait (futures);
0 commit comments