← Todos os modelos

Fluxo de dados unidirecional, um ViewModel por tela, baseline profiles para a inicialização.

Constitution — Android with Jetpack Compose

Version 1.0.0 · Ratified 2026-11-10

These principles hold for every spec, plan and task of the project. A spec may add rules; it never weakens these.

  1. Unidirectional data flow. State flows down and events flow up. Each screen exposes one immutable UI state as a StateFlow, collected with collectAsStateWithLifecycle; composables never change shared state directly.

  2. A ViewModel per screen. Each screen has one ViewModel injected with Hilt that survives configuration changes. State that must survive process death goes through SavedStateHandle.

  3. Baseline profiles for startup. A Macrobenchmark module generates the baseline profile that ships with every release. Cold start stays under 1 s on the reference mid-range device, and a regression in the benchmark fails CI.

  4. State hoisting. Composables take state and event lambdas as parameters and stay stateless where they can, so each one has a @Preview. remember holds only UI state such as an expanded flag.

  5. Cheap recomposition. Parameters are stable or immutable, lazy lists give every item a key, and the Compose compiler reports are checked when a screen changes. A screen that recomposes on every frame is a defect.

  6. Structured coroutines. Work runs in viewModelScope or lifecycleScope with injected dispatchers. GlobalScope and runBlocking on the main thread fail the review.

  7. Accessible by default. Every icon and image has a contentDescription or is marked decorative, touch targets are at least 48 dp and screens are checked with TalkBack. Compose UI tests find nodes by their semantics.

  8. Material 3 theming. Colors and type come from MaterialTheme, with dark theme and dynamic color supported. A hard-coded color in a composable fails the review.