我试图在 lifeCycleScope 之后访问该列表,但它确实只显示了初始值。它只传递初始值!!
setContent {
FlowTheme {
lifecycleScope.launch {
songViewModel = SongViewModel()
songViewModel.getSong()
songViewModel.songStateFlow.buffer().collect {
songList.apply {
add(it)
Log.d("AfterApply", songList.toString())
}
}
Log.d("AfterCollect", songList.toString())
}
Log.d("AfterLifecycle", songList.toString())
}
Body(songList)
}