Join Slack
Powered by
Why is the defaultFactory parameter all of a sudde...
# compose-desktop
g
gbaldeck
02/17/2021, 2:32 PM
Why is the defaultFactory parameter all of a sudden required in compositonLocalOf as of build 154? It has made it difficult to dynamically provide a current value for the compositionLocal
a
Albert Chang
02/17/2021, 2:35 PM
https://kotlinlang.slack.com/archives/C01D6HTPATV/p1613487747011000
g
gbaldeck
02/17/2021, 2:36 PM
thanks
k
Kirill Grouchnikov
02/17/2021, 2:41 PM
You can see that usage in
https://github.com/androidx/androidx/blob/androidx-main/compose/ui/ui/src/androidM[…]ndroidx/compose/ui/platform/AndroidCompositionLocals.android.kt
where an error is thrown if Android-specific providers (that do not have "nice" initial values) are not set before first usage with
https://github.com/androidx/androidx/blob/androidx-main/compose/ui/ui/src/androidM[…]ndroidx/compose/ui/platform/AndroidCompositionLocals.android.kt
Kirill Grouchnikov
02/17/2021, 2:42 PM
Other places like
https://github.com/androidx/androidx/blob/androidx-main/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Colors.kt#L332
to provide a default out of the box
g
gbaldeck
02/17/2021, 2:44 PM
Thanks, in my case the error block worked best
Open in Slack
Previous
Next