component-parcelize
Kotlin Multiplatform support for using android.os.Parcelable from common code.
A full list of kotlin-components projects can be found HERE
Get Started
-
Add dependency to
commonMain// build.gradle.kts dependencies { val vParcelize = "0.1.2" // If usage is a part of your public api, use `api`; otherwise // use `implementation` for internal-only usage. api("io.matthewnelson.kotlin-components:parcelize:$vParcelize") }
// build.gradle dependencies { def vParcelize = "0.1.1" // If usage is a part of your public api, use `api`; otherwise // use `implementation` for internal-only usage. api "io.matthewnelson.kotlin-components:parcelize:$vParcelize" }
-
Add the
kotlin-parcelizeplugin to your projectplugins { id("kotlin-parcelize") }
Usage
-
In
commonMainimport io.matthewnelson.component.parcelize.Parcelable import io.matthewnelson.component.parcelize.Parcelize @Parcelize data class MyData(val value: String): Parcelable
-
Usable from
androidMain// androidMain val intent = Intent() intent.putExtra("MY_DATA", MyData("Parcelable commonMain class")) val myData = intent.getParcelableExtra<MyData>("MY_DATA") println(myData.toString())
-
See the sample-data and sample-app examples
Kotlin Version Compatibility
| parcelize | kotlin |
|---|---|
| 0.1.2 | 1.8.0 |
| 0.1.1 | 1.7.20 |
| 0.1.0 | 1.6.21 |
Git
This project utilizes git submodules. You will need to initialize them when cloning the repository via:
$ git clone --recursive https://github.com/05nelsonm/component-parcelize.gitIf you've already cloned the repository, run:
$ git checkout master
$ git pull
$ git submodule update --initIn order to keep submodules updated when pulling the latest code, run:
$ git pull --recurse-submodules