我正在使用sunflow应用程序示例(https://github.com/android/sunflower)作为学习Hilt、Room和许多其他好的安卓编码概念的基础。
在PlantDetailViewModel类中有以下一行:
val plantId: String = savedStateHandle.get<String>(PLANT_ID_SAVED_STATE_KEY)!!。
但在整个项目中,我看不到设置PLANT_ID_SAVED_STATE_KEY的任何地方。我是不是遗漏了什么?
谢谢
发布于 2022-05-29 19:58:26
它被设置为plantId在PlantDetailViewModel类中的字符串(在第55行),使用:-
companion object {
private const val PLANT_ID_SAVED_STATE_KEY = "plantId"
}https://stackoverflow.com/questions/72424644
复制相似问题