What is everyone using as a date picker in Compose...
# compose
s
What is everyone using as a date picker in Compose land?
c
We are using MaterialDatePickerDialog from Compose and it is working fine, but a bit tricky to get it work
you can get the activity via LocalContext
val activity = LocalContext.current.getActivity()
Copy code
fun Context.getActivity(): FragmentActivity? {
    var currentContext = this

    while (currentContext is ContextWrapper) {
        if (currentContext is FragmentActivity) {
            return currentContext
        }

        currentContext = currentContext.baseContext
    }

    return null
}
and then use the activity to display the date picker dialog
there was no fully working Compose alternative by the time we needed such component (around last September) not sure about now
t
s
thank you both!
f
You can always use the XML date picker inside compose, stackoverflow