What library/libraries do I need to import to use ...
# compose
r
What library/libraries do I need to import to use FlowLayouts? I'm specifically interested in using
FlowRow
. There's plenty of documentation on how to actually use these elements, but nothing consistent on how to import them so they're available. I'm currently importing
androidx.compose.foundation:foundation
, but apparently that's not good enough. I've tried
androidx.compose.foundation:foundation-layout
, but that doesn't help either. None of the documentation or tutorial pages I've seen give useful information on this.
r
Oh sorry, I completely missed that. That would explain it; I'm on 1.4.8.
OK, so I've updated Compose to 1.5.0 and added this to my imports:
Copy code
implementation("androidx.compose.foundation:foundation-layout")
But it's still not finding it. Is there something else I need to add?
r
I would try importing whole foundation and always provide a version number:
implementation("androidx.compose.foundation:foundation:$composeVersion")
r
I'm already importing that, and I'm skipping the version number because I use
compose-bom
and define the Compose version in
composeOptions
. Here's what I have:
Copy code
val composeVersion = findProperty("composeVersion") as String
    composeOptions {
        kotlinCompilerExtensionVersion = composeVersion
    }
    implementation(platform("androidx.compose:compose-bom:2022.12.00"))
    implementation("androidx.compose.ui:ui-tooling")
    implementation("androidx.compose.ui:ui")
    implementation("androidx.compose.ui:ui-tooling-preview")
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.foundation:foundation-layout")
    implementation("androidx.compose.material:material")
    implementation("androidx.compose.material:material-icons-extended")
    implementation("androidx.compose.runtime:runtime")
    implementation("androidx.compose.runtime:runtime-livedata")
Where
composeVersion
is defined in `gradle.properties`:
Copy code
composeVersion=1.5.0
i
"androidx.compose:compose-bom:2022.12.00"
corresponds with Compose 1.3.2: https://developer.android.com/jetpack/compose/bom/bom-mapping
r
Aha!
That would explain a lot.
i
You'll need to use
2023.08.00
if you want Compose 1.5.0
r
OK, got it. Trying that now.
Yep, looks like that fixed it. Makes perfect sense now. Thank you @Ian Lake!
i
You'll also want to make sure you're actually using the latest Compose Compiler for the version of Kotlin you're using: https://developer.android.com/jetpack/androidx/releases/compose-kotlin So you'd probably want to update that to 1.5.2 (note that the versioning for the Compiler is completely independent from the rest of Compose)
r
OK, thank you, I'll check that as well.
i
that way you'll get the latest Compiler bug fixes as well 🙂
r
Very nice. Thank you again! Much appreciated.