0Pricing
Kotlin Multiplatform Academy · Lesson

expect/actual for Device Info

Return OS version and model per platform.

From Interface to expect

Sometimes you skip an interface and use expect/actual directly. It declares device info once in commonMain and implements it per platform.

Declare the expect Class

In commonMain, write an expect class with the device facts you need. There is no body yet, only the shape both platforms must satisfy.

expect class DeviceInfo() {
  val model: String
  val osVersion: String
}

All lessons in this course

  1. Design a Capability Interface
  2. expect/actual for Device Info
  3. File System & Paths per Platform
  4. Inject Platform Implementations
← Back to Kotlin Multiplatform Academy