![]() ![]() ![]() ![]() After seeing this example, its straightforward to use any non-primitive class, just change the implementation and add the appropriate. In this example, I will use the non-natively parcelable class of LocalDateTime, from the shared Kotlin-native kotlinx-datetime library, as the example of non-primitive ‘Parcelable’ class. I will show how to implement the Parcelable interface for Android, and stub the Parcelable interface for iOS (so it is properly ignored), as iOS does not need or use Parcelable. Code needs to be implemented on one platform and ignored on the other platform. The biggest hurdle in implementing cross-platform entities in KMM is properly defining the annotations and setting up the implementation and the “stubs” for each platform. This short article shows you how to work with KMM (Kotlin Multiplatform Mobile) cross-platform annotations, implement a custom for Android Parcelable interface in a KMM project for any Type or Class including primitives. Cross platform annotations are rather confusing at first glance! ![]()
0 Comments
Leave a Reply. |