```val searchQuery = state.getLiveData("query", ""...
# announcements
f
Copy code
val searchQuery = state.getLiveData("query", "")

private val tasksFlow = combine(
        searchQuery.asFlow(),
        preferencesFlow
    ) { query: String, filterPreferences: FilterPreferences ->
        Pair(query, filterPreferences)
    }.flatMapLatest { (query, filterPreferences) ->
        taskDao.getTasks(query, filterPreferences.sortOrder, filterPreferences.hideCompleted)
    }
If I set
searchQuery.value = null
this will crash. How can I get null-safety here?
a
Declare your LiveData with a nullable type if you're going to assign null to it
f
I don't want to assign null to it
LiveData is nullable by default right
a
Yes, LiveData is always nullable, but its observers are declared without nullability annotations
f
it doesn't seem to change anything
The type stays
String!
, I don't get a compiler warning and
asFlow
can still crash