📘
Jetpack Compose - Button を押したら 戻る
きっと以下のどれかでは?
val navController = rememberNavController()
Button(
onClick = { navController.popBackStack() }
) {
Text("back")
}
Divider()
Button(
onClick = { navController.navigateUp() }
) {
Text("back")
}
Divider()
val dispatcher = LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher
Button(
onClick = { dispatcher?.onBackPressed() }
) {
Text("back")
}
Divider()
val activity = LocalContext.current as Activity
Button(
onClick = { activity.finish() }
) {
Text("close")
}
言葉じりと構造よって違うようなので。
Discussion