https://kotlinlang.org logo
#compose
Title
# compose
v

Vivek Sharma

11/30/2020, 9:42 AM
Has anyone used
Snackbar
? I found 2 methods on docs, 1 is taking
boolean state
and making it
visible/hide
on button click but here Snackbar doesn't get disappear after some interval (as we are controlling through state). 2 is when using
Scaffold
, it has
snackbarHost
where we customize our snackbar and display using a
Coroutine Scope
. So how can we make Snackbar hide after some time in 1 method? or should we use 2 method
a

allan.conda

11/30/2020, 9:57 AM
SnackBarHost takes care of that for you
Wrap your SnackBar with SnackBarHost and take the snackbarHostState so you can trigger a snackbar
Scaffold makes that easier for you as it just passes you the snackbarHostState for you to use