Skip to content

Commit 2379787

Browse files
chore: update CHANGELOG for version 0.0.6, fix async/await issues in LocalStorageHelper, enhance HiveCE storage retrieval, and improve UI feedback in example app
1 parent cafaba3 commit 2379787

File tree

8 files changed

+304
-24
lines changed

8 files changed

+304
-24
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.6] - 2026-01-07
9+
10+
### Fixed
11+
- Fixed async/await issue in `LocalStorageHelper.getByKey()` method
12+
- `getByKey()` now properly awaits initialization before retrieving values from HiveCE
13+
- Fixed HiveCE storage retrieval to properly handle async operations
14+
- Improved error handling in `HiveCeStorageCubit.getByKey()` method
15+
16+
### Changed
17+
- `LocalStorageHelper.getByKey()` is now async and properly initializes storage before access
18+
- Updated HiveCE example view to show "Key Not Found" message when value is null
19+
- Improved UI feedback in Get by Key section with color-coded success/error states
20+
21+
[0.0.6]: https://github.com/gurkanfikretgunak/masterfabric_core/releases/tag/v0.0.6
22+
823
## [0.0.5] - 2026-01-07
924

1025
### Added

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Add this to your package's `pubspec.yaml` file:
7070

7171
```yaml
7272
dependencies:
73-
masterfabric_core: ^0.0.5
73+
masterfabric_core: ^0.0.6
7474
```
7575
7676
Then run:
@@ -237,9 +237,15 @@ LocalStorageHelper.setStorageType(LocalStorageType.hiveCe); // or LocalStorageTy
237237
await LocalStorageHelper.setString('key', 'value');
238238
final value = LocalStorageHelper.getString('key');
239239
240+
// Get value by key (supports any type, async)
241+
final dynamicValue = await LocalStorageHelper.getByKey('key');
242+
240243
// Get all items from database
241244
final allItems = await LocalStorageHelper.getAllItems();
242245
246+
// Check if key exists
247+
final exists = LocalStorageHelper.hasKey('key');
248+
243249
// Permissions
244250
final permissionHelper = PermissionHandlerHelper();
245251
final granted = await permissionHelper.requestPermission(Permission.camera);
@@ -300,7 +306,7 @@ For detailed documentation, see:
300306

301307
- **Pub.dev**: [https://pub.dev/packages/masterfabric_core](https://pub.dev/packages/masterfabric_core)
302308
- **GitHub**: [https://github.com/gurkanfikretgunak/masterfabric_core](https://github.com/gurkanfikretgunak/masterfabric_core)
303-
- **Version**: 0.0.5
309+
- **Version**: 0.0.6
304310
- **License**: AGPL-3.0
305311

306312
## Contributing
@@ -331,7 +337,7 @@ Or add it manually to your `pubspec.yaml`:
331337

332338
```yaml
333339
dependencies:
334-
masterfabric_core: ^0.0.5
340+
masterfabric_core: ^0.0.6
335341
```
336342
337343
---

example/lib/features/helpers/helpers_hub_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class HelpersHubView extends StatelessWidget {
108108
),
109109
_HelperItem(
110110
title: 'HiveCE Storage',
111-
description: 'HiveCE storage demo',
111+
description: 'HiveCE storage cases',
112112
icon: LucideIcons.database,
113113
route: app_routes.AppRoutes.hiveCeStorageDemo,
114114
),

example/lib/features/helpers/storage/hive_ce/cubit/hive_ce_storage_cubit.dart

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,32 @@ class HiveCeStorageCubit extends BaseViewModelCubit<HiveCeStorageState> {
1010
Future<void> _loadStoredValues() async {
1111
final allItems = await LocalStorageHelper.getAllItems();
1212
stateChanger(HiveCeStorageState(
13-
storedString: LocalStorageHelper.getString('hivece_demo_string'),
14-
storedInt: LocalStorageHelper.getInt('hivece_demo_int'),
15-
storedBool: LocalStorageHelper.getBool('hivece_demo_bool'),
16-
storedDouble: LocalStorageHelper.getDouble('hivece_demo_double'),
17-
storedStringList: LocalStorageHelper.getStringList('hivece_demo_string_list'),
13+
storedString: LocalStorageHelper.getString('hivece_case_string'),
14+
storedInt: LocalStorageHelper.getInt('hivece_case_int'),
15+
storedBool: LocalStorageHelper.getBool('hivece_case_bool'),
16+
storedDouble: LocalStorageHelper.getDouble('hivece_case_double'),
17+
storedStringList: LocalStorageHelper.getStringList('hivece_case_string_list'),
1818
allItems: allItems,
1919
));
2020
}
2121

22+
/// Get value by key (supports any type)
23+
Future<void> getByKey(String key) async {
24+
try {
25+
final value = await LocalStorageHelper.getByKey(key);
26+
stateChanger(state.copyWith(
27+
retrievedValue: value,
28+
retrievedKey: key,
29+
));
30+
} catch (e) {
31+
// Handle error if needed
32+
stateChanger(state.copyWith(
33+
retrievedValue: null,
34+
retrievedKey: key,
35+
));
36+
}
37+
}
38+
2239
Future<void> loadAllItems() async {
2340
await _loadStoredValues();
2441
}
@@ -49,11 +66,17 @@ class HiveCeStorageCubit extends BaseViewModelCubit<HiveCeStorageState> {
4966
}
5067

5168
Future<void> clearStorage() async {
52-
await LocalStorageHelper.remove('hivece_demo_string');
53-
await LocalStorageHelper.remove('hivece_demo_int');
54-
await LocalStorageHelper.remove('hivece_demo_bool');
55-
await LocalStorageHelper.remove('hivece_demo_double');
56-
await LocalStorageHelper.remove('hivece_demo_string_list');
69+
await LocalStorageHelper.remove('hivece_case_string');
70+
await LocalStorageHelper.remove('hivece_case_int');
71+
await LocalStorageHelper.remove('hivece_case_bool');
72+
await LocalStorageHelper.remove('hivece_case_double');
73+
await LocalStorageHelper.remove('hivece_case_string_list');
74+
await _loadStoredValues();
75+
}
76+
77+
/// Remove item by key
78+
Future<void> removeByKey(String key) async {
79+
await LocalStorageHelper.remove(key);
5780
await _loadStoredValues();
5881
}
5982
}

example/lib/features/helpers/storage/hive_ce/cubit/hive_ce_storage_state.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class HiveCeStorageState extends Equatable {
88
final double? storedDouble;
99
final List<String>? storedStringList;
1010
final Map<String, dynamic>? allItems;
11+
final dynamic retrievedValue;
12+
final String? retrievedKey;
1113

1214
const HiveCeStorageState({
1315
this.storedString,
@@ -16,6 +18,8 @@ class HiveCeStorageState extends Equatable {
1618
this.storedDouble,
1719
this.storedStringList,
1820
this.allItems,
21+
this.retrievedValue,
22+
this.retrievedKey,
1923
});
2024

2125
const HiveCeStorageState.initial()
@@ -24,7 +28,9 @@ class HiveCeStorageState extends Equatable {
2428
storedBool = null,
2529
storedDouble = null,
2630
storedStringList = null,
27-
allItems = null;
31+
allItems = null,
32+
retrievedValue = null,
33+
retrievedKey = null;
2834

2935
HiveCeStorageState copyWith({
3036
String? storedString,
@@ -33,6 +39,8 @@ class HiveCeStorageState extends Equatable {
3339
double? storedDouble,
3440
List<String>? storedStringList,
3541
Map<String, dynamic>? allItems,
42+
dynamic retrievedValue,
43+
String? retrievedKey,
3644
}) {
3745
return HiveCeStorageState(
3846
storedString: storedString ?? this.storedString,
@@ -41,6 +49,8 @@ class HiveCeStorageState extends Equatable {
4149
storedDouble: storedDouble ?? this.storedDouble,
4250
storedStringList: storedStringList ?? this.storedStringList,
4351
allItems: allItems ?? this.allItems,
52+
retrievedValue: retrievedValue ?? this.retrievedValue,
53+
retrievedKey: retrievedKey ?? this.retrievedKey,
4454
);
4555
}
4656

@@ -52,6 +62,8 @@ class HiveCeStorageState extends Equatable {
5262
storedDouble,
5363
storedStringList,
5464
allItems,
65+
retrievedValue,
66+
retrievedKey,
5567
];
5668
}
5769

0 commit comments

Comments
 (0)