Got this weird error ?? ```FloatingActionButton( ...
# compose
s
Got this weird error ??
Copy code
FloatingActionButton(
        onClick = {
            LaunchedTask {
                scaffoldState.snackbarHostState.showSnackbar(
                    "Hello World..",
                    "",
                    SnackbarDuration.Short
                )
            }
        }
@Composable invocations can only happen from the context of a @Composable function
But it works if I extract LaunchedTask to root of @Composable fuctions ?? Isn't FloatingActionButton also inside the composable function blocks ??
a
The onClick isn't a composable
You could set a state and in the snackbar composable, show or hide based on that state, though
s
yep, ur right.. Thanks.