fromDynamic static method

JsonFormBuilder? fromDynamic(
  1. dynamic map, {
  2. JsonWidgetRegistry? registry,
})

Builds the builder from a Map-like dynamic structure. This expects the JSON format to be of the following structure:

{
  "autovalidateMode": <AutovalidateMode>,
  "onChanged": <VoidCallback>,
  "onWillPop": <WillPopCallback>
}

As a note, the VoidCallback and WillPopCallback cannot be decoded via JSON. Instead, the only way to bind those values to the builder is to use a function or a variable reference via the JsonWidgetRegistry.

See also:

Implementation

static JsonFormBuilder? fromDynamic(
  dynamic map, {
  JsonWidgetRegistry? registry,
}) {
  JsonFormBuilder? result;

  if (map != null) {
    result = JsonFormBuilder(
      autovalidateMode: map['autovalidate'] == null
          ? ThemeDecoder.decodeAutovalidateMode(map['autovalidateMode'])
          : JsonClass.parseBool(map['autovalidate']) == true
              ? AutovalidateMode.always
              : AutovalidateMode.disabled,
      onChanged: map['onChanged'],
      onWillPop: map['onWillPop'],
    );
  }

  return result;
}