Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Form state in Jetpack Compose feels difficult because several separate concerns often get packed into one: who owns each value, how edits reach business logic, how text editing stays synchronized, and what happens when the screen is recreated. The key choice is not simply “ViewModel or composable”; it is which state model fits the field’s editing behavior and the rest of your app.

Why forms expose friction in Compose

Compose is declarative: the UI displays the state it receives, and user actions request changes to that state. That makes state flow explicit and supports reusable UI, but a form adds concerns that do not always fit neatly into one representation. A field has text and selection while someone edits it; the app may also need validation, persistence, and a screen-level data model.

With a value-based text field, the composable receives a value and reports proposed changes through onValueChange. The owner processes each edit and supplies the updated value back to the field. This gives the app a clear source of truth, but the round trip can become difficult to coordinate when editing state and a ViewModel’s model are both trying to represent the same input. Android’s migration guidance warns of deep synchronization issues with this approach for text input. Android Developers’ migration guide also says that its newer TextFieldState design is not directly compatible with a StateFlow-backed ViewModel UI state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

That is an architectural tradeoff, not evidence that every Compose form is broken or that every app should put UI state in a ViewModel. State-based fields manage richer editing state, while teams using immutable UI models must decide how to connect that state to their existing architecture.

#1 Best Overall
Sale
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Choose the owner based on who needs the value

Keep state close to the code that reads and changes it, and move it upward only when other code needs access. Android’s state-hoisting guidance puts the rule this way: “You should hoist UI state to the lowest common ancestor between all the composables that read and write it.” See Where to hoist state and State and Jetpack Compose.

Situation State owner and pattern Why it fits
One simple field, with no logic outside its composable Keep the state near the composable; use the field API supported by the project’s Compose and Material versions. Avoids hoisting state that no other code needs.
Several composables read or change the same value Hoist it to their lowest common ancestor and pass the state and events. Provides one shared source of truth without moving state farther up than necessary.
Business logic needs the current input Place the relevant state in a screen-level holder, or connect UI-owned field state to that logic deliberately. The owner should reflect which code needs the value, not a blanket rule about forms.
State-based fields are practical for a new or changing architecture Consider holding TextFieldState in the ViewModel, following the official migration example. It avoids having a StateFlow string model directly drive the field’s editing state.
An existing immutable UiState architecture must remain Keep the model as a data holder and observe field text with snapshotFlow. Android documents this as an alternative; in this arrangement, the StateFlow model does not drive the text fields directly.
Input must survive activity or process recreation Choose a saving approach that matches the owner: use rememberSaveable for Composition-scoped state, or handle save and restore separately for ViewModel-owned TextFieldState. Restoration depends on where the state lives.

What changes with state-based text fields

A string is not the whole state of an actively edited field. Selection matters too, and the state-based API’s TextFieldState manages text and selection in a dedicated holder. This provides a more complete input-state model than passing only a string through a value-and-callback loop. The official text-field documentation describes the state-based approach, but its version context matters: the retrieved feature comparison labels it experimental and cites Material 3 version 1.4.0-alpha14. That is not a timeless status. Check the current documentation and your project’s Compose and Material 3 dependency versions before adopting it.

Rank #2
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.

Holding TextFieldState in a ViewModel is not inherently wrong: Android describes it as a Compose snapshot-backed state holder without UI elements. But it is a different fit from treating an immutable UiState backed by StateFlow as the direct driver of every field.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Option 1: Let the ViewModel hold TextFieldState

Android’s migration guide recommends this as the simpler path when adopting state-based fields. The ViewModel owns the field state, and the UI uses it rather than translating every edit through a StateFlow string model. This can simplify synchronization, but it changes how input is represented in the screen architecture and requires separate save-and-restore handling if the ViewModel owns the TextFieldState.

Rank #3
Sale
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Option 2: Keep the existing ViewModel data model and bridge field state

If replacing an established immutable UI model is impractical, Android documents observing the Compose field state with snapshotFlow. In this arrangement, the existing ViewModel model remains a data holder, but it does not drive the text fields directly. Treat this as an explicit bridge between two state systems, not as a way to make a StateFlow string model and a state-based field interchangeable.

Plan restoration separately from ownership

Decide what should happen to unfinished input when an activity or process is recreated; the answer depends on where the field state is owned. Compose’s state-saving guide explains restoration options, including rememberSaveable for UI state. ViewModel-owned TextFieldState needs separate save-and-restore handling. Saved instance state is intended for small amounts of transient UI state, not large objects.

Rank #4
Sale
Samsung Galaxy S26 Ultra, Unlocked Android Smartphone, 512GB, Black
  • PRIVACY DISPLAY: Automatically hide your screen from those beside you. The built-in privacy display can be preset¹ to turn on when receiving notifications, typing passwords, or using specific apps
  • TYPE IT IN. TRANSFORM IT FAST: Enhance any shot in seconds on your smartphone by using Photo Assist² with Galaxy AI.³ Add objects, restore details, or apply new styles by simply typing or tapping
  • NIGHTS, CAPTURED CLEARLY: From gigs to city lights, record and capture moments after dark with clarity using Nightography so your photos and videos stay crisp and clear on your Samsung Galaxy
  • MAKE IT. EDIT IT. SHARE IT: Turn everyday moments into something personal with creative tools built right into your mobile phone, whether it’s a special contact photo, custom wallpaper, an invitation or more⁴
  • HELP THAT KEEPS UP: Stay in the moment while Now Nudge with Galaxy AI helps you respond faster and stay organized with smart suggestions⁵ that appear exactly when you need them on your phone
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Make the decision without overengineering

  • Start with the smallest owner that serves every reader and writer: a composable for local state, a shared ancestor for shared UI state, or a screen-level holder when business logic needs the value.
  • Choose the field API only after checking the project’s dependency versions and the API’s current stability.
  • If using value-based fields, keep the ownership and edit-update path clear so multiple representations do not compete to be the source of truth.
  • If adopting state-based fields, choose deliberately between ViewModel-owned TextFieldState and an observed-state bridge for an existing immutable model.
  • Handle restoration as its own requirement; do not assume that choosing a ViewModel or a field API automatically saves input.

Android’s official examples describe architectural options, not comparative performance measurements. The useful decision criteria are ownership, testability, editing and synchronization behavior, compatibility with your existing state architecture, restoration needs, and API stability.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a guided grounding in Compose state, see the official State in Jetpack Compose codelab.

Quick Recap

Best Value
Tracfone Moto g Play 2024 Prepaid Phone with a 1-Yr Plan Included
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Activating is easy, just 3 steps.
  • ACTIVATION Promotion: Includes 1500 min, 1500 texts & 1500 MB Data + add more as you need it
  • CAMERA SYSTEM: 50MP Quad Pixel camera. Capture sharper, more vibrant photos day or night with 4x the light sensitivity.
  • PERFORMANCE: Blazing-fast Qualcomm performance. Get the speed you need for great entertainment with a Snapdragon 680 processor and 4GB of RAM.
  • 64GB built-in storage. Get plenty of room for photos, movies, songs, and apps. Made for US

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.