https://kotlinlang.org logo
#compose
Title
# compose
v

Vaibhav Jaiswal

02/28/2024, 10:32 AM
When creating a Compose Multiplatform Project and using Material 3 Which dependencies, do i need to add,
compose.material3
only, or
compose.runtime
,
compose.foundation
etc etc too
j

Joel Denke

02/28/2024, 10:33 AM
I think if I remember correct, those takes transitive deps automatic, but correct me if I am wrong here 🙂 Because they sharing same androidx package names it will be resolved automatic I think.
v

Vaibhav Jaiswal

02/28/2024, 10:35 AM
I need Material3, Material Icons and all basic compose stuff, like Rows, modifiers, states etc Does Material3 has transitive dependency on runtime and foundation?
p

Pablichjenkov

02/28/2024, 10:35 AM
Sometimes compose.ui
too
j

Joel Denke

02/28/2024, 10:36 AM
Right, yeah Row, States etc not part of the Material libs. So then need to add compose.ui, compose.foundation and compose.ui 🙂
p

Pablichjenkov

02/28/2024, 10:36 AM
On foundation I believe
v

Vaibhav Jaiswal

02/28/2024, 10:36 AM
its quite confusing, should i add all foundation, runtime and ui , or using ui include both, what all material includes Should be mentioned somewhere
j

Joel Denke

02/28/2024, 10:36 AM
So code inside Material has its own resolved things, where not neccessarily same compossable source code youre using in your project, depedning how resolve hthe libraries 😛
p

Pablichjenkov

02/28/2024, 10:37 AM
The stack from bottom to top is: 1 runtime 2 ui 3 foundation 4 material
j

Joel Denke

02/28/2024, 10:38 AM
Imagine you only using Button composable from M3 library, and NOTHING from foundation yourself, then I think only need material 🙂 But in almost all cases need foundation and runtime, so good adding them as well.
p

Pablichjenkov

02/28/2024, 10:38 AM
I add them explicitly all the time
1
j

Joel Denke

02/28/2024, 10:39 AM
https://androidx.tech/artifacts/compose.material3/material3-android/1.2.0 You can see here as of example which deps it has 🙂
Just keep in mind this is for Android target, so different in CMP kind a 🙂
v

Vaibhav Jaiswal

02/28/2024, 10:39 AM
I think safest is to add all ,
ui
,
runtime
,
foundation
explicitly
2
j

Joel Denke

02/28/2024, 10:39 AM
@Pablichjenkov Yes me too, just not neccessarly needed but in most cases you probably want it 😛
Also dont forget compose.materialIconsExtended, if using icons as I think mentioned 🙂
v

Vaibhav Jaiswal

02/28/2024, 10:41 AM
Docs should explain this, there are
animation
and
animationGraphics
too, now its included in
ui
or not? Though i can access
Animatable
without it
j

Joel Denke

02/28/2024, 10:42 AM
But yeah I totally agree should be more clear in documenation when to use what, and how Jetbrains resolve all these deps based on platform. Like iOS not getting same implementation as Android getting for same class/methods. Especially if override the versions yourself in Gradle can be very tricky.
p

Pablichjenkov

02/28/2024, 11:05 AM
Yes not needed but just for safety. I recall a bug in js target I believe, where you had to explicitly import it
4 Views