Skip to content

Commit 33bd2af

Browse files
committed
Rename Settings class to EasySettings
1 parent 53f7f52 commit 33bd2af

File tree

11 files changed

+97
-72
lines changed

11 files changed

+97
-72
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.0
2+
3+
* **Breaking**: Renamed `Settings` to `EasySettings` to avoid potential conflicts with a commonly used name.
4+
15
## 1.0.1
26

37
* Updated `shared_preferences` and `logging` dependencies

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void main() {
251251
late Settings settings;
252252
253253
setUp(() {
254-
settings = Settings();
254+
settings = EasySettings();
255255
settings.register(SettingsGroup.forTesting(
256256
key: 'test',
257257
items: [
@@ -282,7 +282,7 @@ void main() {
282282

283283
### Main API
284284

285-
- `Settings()`: Main settings manager
285+
- `EasySettings()`: Main settings manager
286286
- `SettingsGroup()`: Container for related settings
287287
- `settings.register()`: Register a settings group
288288
- `settings.init()`: Initialize the settings system

example/integration_test/app_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ void main() {
88

99
group('Easy Shared Preferences Integration Tests', () {
1010
late SettingsStore store;
11-
late Settings settings;
11+
late EasySettings settings;
1212

1313
setUp(() async {
1414
// Initialize store and settings for each test
1515
store = SettingsStore();
16-
settings = Settings(store: store);
16+
settings = EasySettings(store: store);
1717

1818
// Clear any existing data
1919
await store.readyFuture;
@@ -63,7 +63,7 @@ void main() {
6363
settings.dispose();
6464

6565
final newStore = SettingsStore();
66-
final newSettings = Settings(store: newStore);
66+
final newSettings = EasySettings(store: newStore);
6767
final newTestGroup = SettingsGroup(
6868
key: 'integration_test',
6969
items: [

example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import 'package:easy_shared_preferences/easy_shared_preferences.dart';
44
late SettingsStore store;
55
late SettingsGroup gameSettings;
66
late SettingsGroup uiSettings;
7-
late Settings settings;
7+
late EasySettings settings;
88

99
void main() async {
1010
WidgetsFlutterBinding.ensureInitialized();
1111

1212
// Initialize store and settings
1313
store = SettingsStore();
14-
settings = Settings(store: store);
14+
settings = EasySettings(store: store);
1515

1616
// Define your settings groups with both function and class validators
1717
gameSettings = SettingsGroup(

example/lib/type_system_example.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void main() async {
1010
// Initialize settings
1111
WidgetsFlutterBinding.ensureInitialized();
1212
final store = SettingsStore();
13-
final settings = Settings(store: store);
13+
final settings = EasySettings(store: store);
1414

1515
final gameSettings = SettingsGroup(
1616
key: 'game',

lib/src/global_settings.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class GroupConfig {
5959
/// Helper class that eliminates duplication by providing a single method
6060
/// to check initialization and delegate to the underlying instance.
6161
class _GlobalSettingsDelegate {
62-
static Settings? _instance;
62+
static EasySettings? _instance;
6363

6464
/// Get the instance and ensure it's initialized
65-
static Settings get instance {
65+
static EasySettings get instance {
6666
if (_instance == null) {
6767
throw StateError(
6868
'GlobalSettings has not been initialized. Call GlobalSettings.initialize() first.');
@@ -71,7 +71,7 @@ class _GlobalSettingsDelegate {
7171
}
7272

7373
/// Set the instance (internal use only)
74-
static void _setInstance(Settings? instance) {
74+
static void _setInstance(EasySettings? instance) {
7575
_instance = instance;
7676
}
7777
}
@@ -123,10 +123,10 @@ class GlobalSettings {
123123
_logger
124124
.info('Initializing GlobalSettings with ${groupConfigs.length} groups');
125125

126-
Settings? tempInstance;
126+
EasySettings? tempInstance;
127127
try {
128128
final settingsStore = store ?? SettingsStore();
129-
tempInstance = Settings(store: settingsStore);
129+
tempInstance = EasySettings(store: settingsStore);
130130

131131
// Create and register all groups
132132
for (final config in groupConfigs) {
@@ -207,7 +207,7 @@ class GlobalSettings {
207207
/// Most users should use the convenience methods instead.
208208
///
209209
/// Throws [StateError] if not initialized.
210-
static Settings get instance => _GlobalSettingsDelegate.instance;
210+
static EasySettings get instance => _GlobalSettingsDelegate.instance;
211211

212212
/// Dispose the global settings and cleanup all resources.
213213
///

lib/src/settings_manager.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'typed_setting_access.dart';
77

88
/// Settings manager providing centralized access to all setting groups.
99
///
10-
/// The [Settings] class serves as the main entry point for the settings framework,
10+
/// The [EasySettings] class serves as the main entry point for the settings framework,
1111
/// offering instance methods for registration, initialization, and access to settings
1212
/// across your entire application. It manages multiple [SettingsGroup] instances and
1313
/// provides both individual and batch operations with proper resource management.
@@ -16,7 +16,7 @@ import 'typed_setting_access.dart';
1616
///
1717
/// The settings framework follows a hierarchical structure:
1818
/// ```
19-
/// Settings (Global Manager)
19+
/// EasySettings (Manager)
2020
///
2121
/// ├── SettingsGroup (Group: "game")
2222
/// │ ├── BoolSetting ("soundEnabled")
@@ -92,7 +92,7 @@ import 'typed_setting_access.dart';
9292
///
9393
/// This prevents key conflicts between different setting groups and provides
9494
/// logical organization of related settings.
95-
class Settings with TypedSettingAccess {
95+
class EasySettings with TypedSettingAccess {
9696
static final _logger = EspLogger.forComponent('Settings');
9797

9898
/// The settings store instance used by this manager.
@@ -121,7 +121,7 @@ class Settings with TypedSettingAccess {
121121
///
122122
/// Parameters:
123123
/// - [store]: The SettingsStore to use for persistence. If not provided, creates a new one.
124-
Settings({SettingsStore? store}) : _store = store ?? SettingsStore() {
124+
EasySettings({SettingsStore? store}) : _store = store ?? SettingsStore() {
125125
_logger.info('Creating Settings manager');
126126
}
127127

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: easy_shared_preferences
22
description: A flexible, hierarchical wrapper for flutter's shared_preferences package.
3-
version: 1.0.1
3+
version: 1.1.0
44
homepage: https://github.com/NexusDynamic/easy_shared_preferences
55
repository: https://github.com/NexusDynamic/easy_shared_preferences
66
issue_tracker: https://github.com/NexusDynamic/easy_shared_preferences/issues

test/easy_shared_preferences_test.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import 'package:easy_shared_preferences/easy_shared_preferences.dart';
55
void main() {
66
// Set up Flutter test environment
77
TestWidgetsFlutterBinding.ensureInitialized();
8-
8+
99
group('Settings Framework Tests', () {
10-
late Settings appSettings;
10+
late EasySettings appSettings;
1111
late SettingsStore store;
12-
12+
1313
setUp(() async {
1414
// Clear SharedPreferences before each test using the simpler mock approach
1515
// This is compatible with both SharedPreferences and SharedPreferencesWithCache
1616
SharedPreferences.setMockInitialValues({});
1717

1818
// Create fresh instances for each test
1919
store = SettingsStore(forceRegularSharedPreferences: true);
20-
appSettings = Settings(store: store);
20+
appSettings = EasySettings(store: store);
2121
});
2222

2323
tearDown(() async {
@@ -560,8 +560,8 @@ void main() {
560560

561561
// Create new Settings instance and store for second initialization
562562
final newStore = SettingsStore(forceRegularSharedPreferences: true);
563-
final newSettings = Settings(store: newStore);
564-
563+
final newSettings = EasySettings(store: newStore);
564+
565565
// Second initialization with same structure
566566
final settings2 = SettingsGroup.forTesting(
567567
key: 'persist-test',
@@ -969,8 +969,8 @@ void main() {
969969

970970
// Create new Settings instance and store
971971
final newStore = SettingsStore(forceRegularSharedPreferences: true);
972-
final newSettings = Settings(store: newStore);
973-
972+
final newSettings = EasySettings(store: newStore);
973+
974974
// Create new instance with same key structure
975975
final settings2 = SettingsGroup.forTesting(
976976
key: 'persist',
@@ -986,7 +986,7 @@ void main() {
986986
// Values should be persisted
987987
expect(newSettings.getBool('persist.flag'), isTrue);
988988
expect(newSettings.getString('persist.text'), equals('persisted'));
989-
989+
990990
// Clean up
991991
newSettings.dispose();
992992
});
@@ -1006,8 +1006,8 @@ void main() {
10061006

10071007
// Create new Settings instance and store
10081008
final newStore = SettingsStore(forceRegularSharedPreferences: true);
1009-
final newSettings = Settings(store: newStore);
1010-
1009+
final newSettings = EasySettings(store: newStore);
1010+
10111011
// Create expanded settings with new setting
10121012
final expandedSettings = SettingsGroup.forTesting(
10131013
key: 'expand',
@@ -1025,7 +1025,7 @@ void main() {
10251025

10261026
// New setting should use default
10271027
expect(newSettings.getInt('expand.newSetting'), equals(42));
1028-
1028+
10291029
// Clean up
10301030
newSettings.dispose();
10311031
});

test/global_settings_test.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:easy_shared_preferences/easy_shared_preferences.dart';
44

55
void main() {
66
TestWidgetsFlutterBinding.ensureInitialized();
7-
7+
88
group('GlobalSettings Tests', () {
99
setUp(() async {
1010
SharedPreferences.setMockInitialValues({});
@@ -118,7 +118,8 @@ void main() {
118118
GlobalSettings.dispose();
119119

120120
expect(() => GlobalSettings.getBool('app.darkMode'), throwsStateError);
121-
expect(() => GlobalSettings.setBool('app.darkMode', true), throwsA(isA<StateError>()));
121+
expect(() => GlobalSettings.setBool('app.darkMode', true),
122+
throwsA(isA<StateError>()));
122123
});
123124
});
124125

@@ -186,7 +187,7 @@ void main() {
186187

187188
test('should call change callbacks', () async {
188189
final changeEvents = <Map<String, dynamic>>[];
189-
190+
190191
GlobalSettings.addChangeCallback((key, oldValue, newValue) {
191192
changeEvents.add({
192193
'key': key,
@@ -205,7 +206,7 @@ void main() {
205206

206207
test('should remove change callbacks', () async {
207208
final changeEvents = <Map<String, dynamic>>[];
208-
209+
209210
void callback(String key, dynamic oldValue, dynamic newValue) {
210211
changeEvents.add({
211212
'key': key,
@@ -290,7 +291,7 @@ void main() {
290291
await GlobalSettings.initialize(groups);
291292

292293
final instance = GlobalSettings.instance;
293-
expect(instance, isA<Settings>());
294+
expect(instance, isA<EasySettings>());
294295
expect(instance.getBool('test.flag'), isFalse);
295296
});
296297

@@ -333,4 +334,4 @@ void main() {
333334
});
334335
});
335336
});
336-
}
337+
}

0 commit comments

Comments
 (0)