← All blogs

dust blog

Read State During Build

Dust State Management example showing watchXViewModel value and readXViewModel

One State Management rule is worth keeping strict.

Use watchXViewModel().value only where UI should rebuild. Use readXViewModel() in callbacks, lifecycle methods, and dependency factories.

Dust generates those ViewModel accessors from @ViewModel. Reading state during build and calling commands without subscribing stay separate.

Read the Dust State Management guide.

#Dust #State #Flutter #Dart #CodeGeneration