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
- Design a Capability Interface
- expect/actual for Device Info
- File System & Paths per Platform
- Inject Platform Implementations