ComposePreferences icon indicating copy to clipboard operation
ComposePreferences copied to clipboard

Nullable value in PreferenceRequest

Open jakoss opened this issue 4 years ago • 0 comments

Love the concept of the library, but i have slight problem with it's usage (PreferenceRequest to be exact). I have some setting that i want to be nullable. But right now it is simply not possible, since the T have to be the same type as the preferencesKey from DataStore. Since DataStore CAN return store null with non-nullable generic argument then we have a type missmatch here. Example:

val nullableRequest = PreferenceRequest<String?>(
    key = stringPreferencesKey("test"),
    defaultValue = null
)

jakoss avatar Jun 21 '21 10:06 jakoss