Skip to content

Instantly share code, notes, and snippets.

@wangerekaharun
Created October 27, 2019 10:41
Show Gist options
  • Save wangerekaharun/2e5cef7cf7ef5667d037f108bd09e80a to your computer and use it in GitHub Desktop.
Save wangerekaharun/2e5cef7cf7ef5667d037f108bd09e80a to your computer and use it in GitHub Desktop.
Sample code for filtering a list in compose
@Composable
fun FilteredList(contacts : List<Contact>, filterTet : String = ""){
val state = +state { filterTet }
VerticalScroller{
Column{
TextField(filterText, onValueChange { state.value = it }){
contacts.filter{ it.contains(state.value) }.forEach {
Row{
Image(it.photo)
Text(it.name
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment