Skip to content

Instantly share code, notes, and snippets.

@MachFour
Created December 21, 2023 02:23
Show Gist options
  • Save MachFour/f0fd1aa12705c055edacc939a14e7852 to your computer and use it in GitHub Desktop.
Save MachFour/f0fd1aa12705c055edacc939a14e7852 to your computer and use it in GitHub Desktop.
Jetpack Compose crash
import androidx.compose.foundation.layout.*
import androidx.compose.material.DropdownMenu
import androidx.compose.material.DropdownMenuItem
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
@Preview
@Composable
fun Preview() {
val expanded by remember { mutableStateOf(false) } // works if set to true
Surface {
Column(
modifier = Modifier.width(IntrinsicSize.Min)
) {
OutlinedTextField(
value = "",
onValueChange = { },
trailingIcon = {
DropdownMenu(
expanded = expanded,
onDismissRequest = { },
) {
DropdownMenuItem({ }) { Text("") }
}
}
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment