Skip to content

crash after deleting item #181

@ignatius2138

Description

@ignatius2138

Am i the only one getting crash with error: java.lang.IllegalStateException: The query result was empty, but expected a single row to return a NON-NULL object of type <com.example.inventory.data.Item>. When we delete item the ui is still observing UiState and when we delete the item, getItem returns null which room doesnt expect because return value of getItem is Item.
I fixed this by getItem return Item? and then in viewmodel checking for null

.map {item ->
                if (item == null) {
                    ItemDetailsUiState()
                } else {
                    ItemDetailsUiState(
                        outOfStock = item.quantity <= 0,
                        itemDetails = item.toItemDetails()
                    )
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions