Is Compose Multiplatform native on android and ios...
# compose-ios
s
Is Compose Multiplatform native on android and ios? I searched across but couldn't find any satisfactory answer. Is it just a flutter 2.0?
c
What do you mean by "native on Android and iOS"? How do you define "Flutter 2.0"?
Compose is built on Kotlin multiplatform. And that compiles to the native code on each platform. So in that sense it is native (unlike Flutter). Compose however does not use the native UI widgets on each platform. Instead it basically renders the UI on a Canvas. In that sense it is like Flutter.
☝️ 3
☝🏻 1
k
best answer @curioustechizen
a
@curioustechizen so compose multiplatform widgets/layout is rendered on top of a canvas ?
h
You could also write a compose based runtime which uses UIKit, like redwood.
👍🏻 1
👍 1
l
Although Compose renders on a View's canvas on Android, you could consider Compose 'native' on Android since it's the first party and recommended UI library.
z
You can take the Android side as a Native. Because the Jetpack Compose is specially developed for Android By Google to replace XML. Jetbrains just forked it and ported it to work for other platforms. So there is nothing to lose in Android. It's like writing your source code in a library. Regarding iOS, the same compose UI is drawn in a canvas. KMP is much more scalable. You won't get into a situation where you have to leave KMP and opt for other. Using Flutter, you might have to
b
@curioustechizen’s answer is technically correct "Compose however does not use the native UI widgets on each platform." But it misses an important detail. Compose for Android and iOS both have full interop with Android Views and iOS UIKit; you can embed native platform views anywhere in your Compose screen.
So, you actually have the option to, for example, use the Switch composable provided by Compose Material UI on iOS, or instead embed iOS's UISwitch for a more native feel.
You as the developer always have full full control over how much to share or customize per platform, and that's the beauty of Kotlin/Compose multiplatform.
❤️ 2
K 2
💯 2
l
That concept is a bit complicated by the fact that on Android (last I checked at least), Compose renders Views you're interopping with offscreen and draws the result to its actual canvas, making the view 'native compose'. On iOS, this is not the case. It's just an iOS view positioned over the Compose canvas.
b
Yeah but that's more of an implementation detail (how the pixels make it on the screen). It is still the real iOS/Android view's code determining what the widget looks like and how it behaves. It's not a clone / look-alike. And you can also use most 3rd party UIKit or SwiftUI libraries alongside Compose.
👍 1