Whats the correct way to pass a string resource (a...
# compose
f
Whats the correct way to pass a string resource (as an Int) to
scaffoldState.snackbarHostState.showSnackbar
? I can't use
stringResource
there since that's a Composable.
d
Get the string earlier in a composable function.
f
but it's passed as an argument
d
Yeah where are you keeping this state? In a viewmodel?
f
it's sent as a one-off event from the ViewModel
through a Flow which I colled in LaunchedEffect
d
Ah then idk. Probably best to use
Context
to get the string at that point.
f
yea but I don't know how to get the context either 🤔
LocalContext.current doesn't work either
I guess I can pass it from the activity but I don't know if that's good
d
Are you not using
AndroidViewModel
?
f
No. But Zhuinden said I can just call LocalContext.current above the LaunchedEffect
and then just use it inside it
no idea if that causes any problems
f
great, thank you 👍