Skip to content

Commit

Permalink
Fix export for data
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Aug 7, 2024
1 parent 8bef885 commit 02cd42c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/lw_file_system_api/lib/src/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class ArchiveState with ArchiveStateMappable {
final Set<String> removed;

const ArchiveState({this.added = const {}, this.removed = const {}});

bool get isDirty => added.isNotEmpty || removed.isNotEmpty;
}

abstract class ArchiveData<T> {
Expand All @@ -28,6 +30,9 @@ abstract class ArchiveData<T> {
state = ArchiveState();

Archive export() {
if (!state.isDirty) {
return this.archive;
}
final archive = Archive();
for (final entry in state.added.entries) {
archive.addFile(ArchiveFile(entry.key, entry.value.length, entry.value));
Expand All @@ -42,9 +47,8 @@ abstract class ArchiveData<T> {
return archive;
}

List<int>? exportBytes() {
return ZipEncoder().encode(export());
}
Uint8List exportAsBytes() =>
Uint8List.fromList(ZipEncoder().encode(export()) ?? []);

Uint8List? getAsset(String name) {
final added = state.added[name];
Expand Down

0 comments on commit 02cd42c

Please sign in to comment.