decodeToolbarOptions static method

ToolbarOptions? decodeToolbarOptions(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the given value to a ToolbarOptions. This expects the value to have the following structure:

{
  "copy": <bool>,
  "cut": <bool>,
  "paste": <bool>,
  "selectAll": <bool>
}

Implementation

static ToolbarOptions? decodeToolbarOptions(
  dynamic value, {
  bool validate = true,
}) {
  ToolbarOptions? result;
  if (value is ToolbarOptions) {
    result = value;
  } else if (value != null) {
    assert(SchemaValidator.validate(
      schemaId: '$_baseSchemaUrl/toolbar_options',
      value: value,
      validate: validate,
    ));
    result = ToolbarOptions(
      copy: JsonClass.parseBool(value['copy']),
      cut: JsonClass.parseBool(value['cut']),
      paste: JsonClass.parseBool(value['paste']),
      selectAll: JsonClass.parseBool(value['selectAll']),
    );
  }

  return result;
}