Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the Snackbar example correct? #290

Closed
FANMixco opened this issue Jul 15, 2024 · 3 comments
Closed

Is the Snackbar example correct? #290

FANMixco opened this issue Jul 15, 2024 · 3 comments
Assignees

Comments

@FANMixco
Copy link

FANMixco commented Jul 15, 2024

Fellows,

I was trying to follow this example:
https://developer.android.com/develop/ui/compose/components/snackbar

But I cannot find how to enable both options like in the image:

image

I want to have the X to dismiss and the action. Is it possible? Or is the image wrong? Since I cannot find the way to enable it. Thanks.

@Jenish-1235
Copy link

@JolandaVerhoef Hey, I would like to work around this issue... Can I know the current status of this issue ?

@JolandaVerhoef
Copy link
Contributor

You can add withDismissAction = true to the showSnackbar call:

                        val result = snackbarHostState
                            .showSnackbar(
                                message = "Snackbar",
                                withDismissAction = true, // << ADD THIS
                                actionLabel = "Action",
                                // Defaults to SnackbarDuration.Short
                                duration = SnackbarDuration.Indefinite
                            )

@FANMixco
Copy link
Author

You can add withDismissAction = true to the showSnackbar call:

                        val result = snackbarHostState
                            .showSnackbar(
                                message = "Snackbar",
                                withDismissAction = true, // << ADD THIS
                                actionLabel = "Action",
                                // Defaults to SnackbarDuration.Short
                                duration = SnackbarDuration.Indefinite
                            )

But that's not the issue, the problem is that the documentation is incorrect. The example is not there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants