Skip to content

Commit 2f34dca

Browse files
committed
SDK Local Storage #5
- Add option to clear storage.
1 parent 512a593 commit 2f34dca

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/src/api/models/action/set_storage_action.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// All rights reserved. Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE.md file.
44

5-
import 'package:equatable/equatable.dart';
65
import 'package:codelessly_json_annotation/codelessly_json_annotation.dart';
6+
import 'package:equatable/equatable.dart';
77

88
import '../../mixins.dart';
99
import '../models.dart';
@@ -16,13 +16,26 @@ enum StorageOperation {
1616
remove,
1717

1818
/// Add or update the data in storage.
19-
addOrUpdate;
19+
addOrUpdate,
20+
21+
/// Clear all data from storage.
22+
clear;
2023

2124
/// Displayable string representation of the [StorageOperation].
2225
String get label => switch (this) {
2326
StorageOperation.addOrUpdate => 'Add/Update',
2427
StorageOperation.remove => 'Remove',
28+
StorageOperation.clear => 'Clear',
2529
};
30+
31+
/// Whether the operation is [StorageOperation.remove].
32+
bool get isRemove => this == StorageOperation.remove;
33+
34+
/// Whether the operation is [StorageOperation.clear].
35+
bool get isClear => this == StorageOperation.clear;
36+
37+
/// Whether the operation is [StorageOperation.addOrUpdate].
38+
bool get isAddOrUpdate => this == StorageOperation.addOrUpdate;
2639
}
2740

2841
/// An action that sets value of a variable.

lib/src/api/models/action/set_storage_action.g.dart

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)