ZenMutationWhenExtension<TData, TVariables> extension
Convenience extension on ZenMutation for declarative UI building.
Useful for driving button loading states, inline form feedback, or any UI element that reflects mutation progress.
Example — loading button:
ElevatedButton(
onPressed: mutation.status.value == ZenMutationStatus.loading
? null
: () => mutation.mutate(args),
child: mutation.when(
idle: () => const Text('Save'),
loading: () => const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
),
success: (_) => const Text('Saved!'),
error: (e) => const Text('Retry'),
),
)
- on
-
- ZenMutation<
TData, TVariables>
- ZenMutation<
Methods
-
when(
{required Widget idle(), Widget loading()?, Widget success(TData data)?, Widget error(Object error)?}) → Widget -
Available on ZenMutation<
Builds UI based on the current mutation state.TData, TVariables> , provided by the ZenMutationWhenExtension extension