SettingsService class Core

Service for storing persistent key/value application settings.

This object provides a simple typed key-value store persisted to a platform-specific location. Values are stored inside a named "group" (the default is DEFAULT) which can be changed with beginGroup/endGroup.

Supported types: String, bool, int (32-bit), large int (64-bit), and double. Changes are buffered and written to disk either automatically or immediately when flush is called.

Example

final settings = SettingsService();
settings.setString('username', 'alice');
settings.setInt('launchCount', 1);
settings.flush(); // ensure values are persisted
final name = settings.getString('username', defaultValue: 'guest');

Constructors

SettingsService({String? path})
Creates or opens a SettingsService at the given path.
factory
SettingsService.init(int id)

Properties

group String
The name of the currently active group.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasRegisteredAutoReleaseObject bool
getter/setter pairinherited
path String
The file system path where this SettingsService stores its values.
no setter
pointerId int
The pointer ID of the native object
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

beginGroup(String groupName) → void
Begin a named group for subsequent keys.
clear() → void
Remove all settings.
dispose() → void
Disposes the native object.
inherited
endGroup() → void
End the current group and revert to DEFAULT.
flush() → void
Force-write pending changes to permanent storage.
getBool(String key, {bool defaultValue = false}) bool
Retrieve a bool value for key.
getDouble(String key, {double defaultValue = 0.0}) double
Retrieve a double value for key.
getInt(String key, {int defaultValue = 0}) int
Retrieve a 32-bit int value for key.
getLargeInt(String key, {int defaultValue = 0}) int
Retrieve a 64-bit integer value for key.
getString(String key, {String defaultValue = ''}) String
Retrieve a String value for key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerAutoReleaseObject(int pointerId) → void
Registers an object for auto release.
inherited
remove(String key) int
Remove the specified setting key or keys matching a pattern.
setBool(String key, bool value) → void
Store a bool value for key.
setDouble(String key, double value) → void
Store a double value for key.
setInt(String key, int value) → void
Store a 32-bit int value for key.
setLargeInt(String key, int value) → void
Store a 64-bit integer value for key.
setString(String key, String value) → void
Store a String value for key.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited