state method
Future<List<SchemaComponent> >
state(
- String resourceKey, {
- Object? recordId,
- required Map<
String, dynamic> values, - required String changed,
override
POST /{resource}/state — re-evaluates the form against values typed but
not yet submitted, so visible/disabled/hidden closures answer on
mobile exactly as they do in the web panel.
Implementation
@override
Future<List<SchemaComponent>> state(
String resourceKey, {
Object? recordId,
required Map<String, dynamic> values,
required String changed,
}) async {
final response = await _transport.post('$prefix/$resourceKey/state', {
'record_id': recordId,
'state': values,
'changed': changed,
});
// Unlike the writes, `state()` has no data-carrying failure outcome to
// return — its contract is "the current form", not a result union — so a
// non-2xx throws here exactly as `get()` does, rather than silently
// parsing an error body's absent `components` key as an empty form.
if (response.statusCode < 200 || response.statusCode >= 300) {
throw FilamentTransportException(_messageOf(response.body));
}
return SchemaComponent.listFromJson(
response.body,
'components',
'$resourceKey/state',
);
}