0Pricing
Kotlin Multiplatform Academy · Lesson

Map DTOs to Domain Models

Separate network shapes from your domain types.

Two Kinds of Models

Your app actually has two shapes of data: the raw DTO from the API and the clean domain model your code wants.

What a DTO Is

A DTO, or data transfer object, mirrors the JSON exactly, even when the field names are messy or awkward.

@Serializable
data class UserDto(val user_name: String, val avatar_url: String?)

All lessons in this course

  1. Define a Repository Interface
  2. Wrap the API Behind the Repository
  3. Map DTOs to Domain Models
  4. Expose Results as Flow
← Back to Kotlin Multiplatform Academy