Tower Guidev2
07/24/2023, 6:02 AMvar
or val
as follows:-
val functionVariable: @Composable () -> Unit = { myComposableFunction() }
however is it possible to define a "getter" NON COMPOSABLE function that returns this variable
whatever i try Android Studio is highlighting compile time errors saying the getters have to be annotated @Composable
if i am simply returning a value thats composable why is that?myanmarking
07/24/2023, 8:57 AMAlbert Chang
07/24/2023, 9:31 AMval functionVariable: @Composable () -> Unit
get() = { myComposableFunction() }
Tower Guidev2
07/24/2023, 10:12 AMoverride fun getTitleByRoute(route: String): String = when (route) {
TopicAlertDestination.route -> TopicAlertDestination.toolBarSubTitle
HistoryDestination.route -> HistoryDestination.toolBarSubTitle
StackGridDestination.route -> StackGridDestination.toolBarSubTitle
BookmarkDestination.route -> BookmarkDestination.toolBarSubTitle
else -> _TODO_("Unknown route = $route")
}
which is called as follows appBarSubtitle = myNavigation.getTitleByRoute(backStackEntry.destination.route!!)
i wish to have a similar function that returns a composable based on the backStackEntry.destination.route
override fun getComposableByRoute(route: String): @Composable () -> Unit = when (route) {
TopicAlertDestination.route -> functionVariable1
HistoryDestination.route -> functionVariable2
StackGridDestination.route -> functionVariable3
BookmarkDestination.route -> functionVariable4
else -> _TODO_("Unknown route = $route")
}