0

So i am working with an app in jetpack compose and i see this tutorial Tutorial. This tutorial builds a default snackbar within a snackbarhost and adds a text to this snackbar in the way below. Though when i try to add this parameter it tells me that it doesn't exist. Why is this is the parameter deprecated and if so what did it get exchanged with? Plus i have the question of how to clear the que in the snackbarhost quz when i click more then once i first get myh last message and then the one i should get?

Snackbar(
  modifier = Modifier.padding(16.dp),
    text = {
      Text(
        text = data.message,
        style = MaterialTheme.typography.body2,
        color = Color.White
      )
      },
            action = {
                data.actionLabel?.let { actionLabel ->
                    TextButton(
                        onClick = {
                            onDismiss()
                        }
                    ) {
             Text(
                text = actionLabel,
                style = MaterialTheme.typography.body2,
                color = Color.White
            )
         }
      }
   }
)
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
jens
  • 207
  • 2
  • 9

1 Answers1

0

I'm assume your talking about this line:

Snackbar(
  modifier = Modifier.padding(16.dp),
  text = { // <--

I found a usage example on the Compose Playground here: https://foso.github.io/Jetpack-Compose-Playground/material/snackbar/ (the page also contains a link to the reference of Snackbar)

From what I can see, they probably replaced the text arg with the content of the Snackbar, which would result in something similar to this:

Snackbar(
  modifier = ... same as before ...,
  action = ... same as before ... 
) {
   // Move the text element here
   Text(...)
}
JensV
  • 3,997
  • 2
  • 19
  • 43
  • Ah okey do you have a clue on how to clear the que of the snackbarhost – jens Jan 14 '22 at 15:54
  • @jens not really. Can't find anything regarding a queue in the default `SnackbarHost`. Either your tutorial explains it or you may be able to find more in the linked compose playground and docs. – JensV Jan 14 '22 at 15:58
  • Yep will take a look thanks – jens Jan 14 '22 at 16:02