getBool method
Gets a boolean value.
Returns defaultValue if the key is missing or the stored type is not bool.
key Lookup key.
defaultValue Value to return when not found or type mismatch.
Returns Stored bool or defaultValue.
Example:
// Retrieve boolean values with defaults
bool isPremium = _userStorage!.getBool("is_premium", false);
bool notificationsEnabled = _userStorage!.getBool(
"notifications_enabled",
true,
);
bool nonExistentBool = _userStorage!.getBool("non_existent_bool", false);
print("Is premium: $isPremium");
print("Notifications enabled: $notificationsEnabled");
print("Non-existent bool: $nonExistentBool");
Implementation
@override
bool getBool(String key, bool defaultValue) {
final _getBoolFfi = __lib.catchArgumentError(() => __lib.nativeLibrary.lookupFunction<
Uint8 Function(Pointer<Void>, Pointer<Void>, Uint8),
int Function(Pointer<Void>, Pointer<Void>, int)
>('navigine_sdk_flutter_KeyValueStorage_getBool__Key_DefaultValue'));
final _keyHandle = navigine_sdk_flutter_String_ToFfi(key);
final _defaultValueHandle = navigine_sdk_flutter_bool_ToFfi(defaultValue);
final _handle = this.handle;
final __resultHandle = _getBoolFfi(_handle, _keyHandle, _defaultValueHandle);
navigine_sdk_flutter_String_ReleaseFfiHandle(_keyHandle);
navigine_sdk_flutter_bool_ReleaseFfiHandle(_defaultValueHandle);
final _result = navigine_sdk_flutter_bool_FromFfi(__resultHandle);
navigine_sdk_flutter_bool_ReleaseFfiHandle(__resultHandle);
return _result;
}