Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behaviour inconsistency across platform #228

Open
dewantawsif opened this issue Feb 19, 2025 · 2 comments
Open

Behaviour inconsistency across platform #228

dewantawsif opened this issue Feb 19, 2025 · 2 comments

Comments

@dewantawsif
Copy link

dewantawsif commented Feb 19, 2025

If you save an String preference with key foo and for reasons known or unknown try to get a Boolean preference with key foo the resulting behavior is different depending on the platform.

In case of Android's SharedPreferences it'll throw ClassCastException (ref), Apple's NSUserDefaults will return NO/false (ref), JVM's PropertiesSettings will just return the default value (ref)

Since multiplatform-settings only calls the platform method and doesn't do any kind of validation/extra work this results in inconsistency

@russhwolf
Copy link
Owner

This inconsistency is known and documented in the getter methods. It's not clear what the best way to work around it would be, but I'm open to suggestions.

@dewantawsif
Copy link
Author

This inconsistency is known and documented in the getter methods.

Oh you're right. The API was so simple I didn't look at the javadocs

It's not clear what the best way to work around it would be, but I'm open to suggestions.

I do have some ideas but it won't really be backwards compatible. Essentially we can store an extra preference to hold the type of the key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants