decodeButtonTextTheme static method

ButtonTextTheme? decodeButtonTextTheme(
  1. dynamic value, {
  2. bool validate = true,
})

Decodes the value to a ButtonTextTheme. Supported values are:

  • accent
  • normal
  • primary

Implementation

static ButtonTextTheme? decodeButtonTextTheme(
  dynamic value, {
  bool validate = true,
}) {
  ButtonTextTheme? result;

  if (value is ButtonTextTheme) {
    result = value;
  } else {
    _checkSupported(
      'ButtonTextTheme',
      [
        'accent',
        'normal',
        'primary',
      ],
      value,
    );

    if (value != null) {
      assert(SchemaValidator.validate(
        schemaId: '$_baseSchemaUrl/button_text_theme',
        value: value,
        validate: validate,
      ));
      switch (value) {
        case 'accent':
          result = ButtonTextTheme.accent;
          break;
        case 'normal':
          result = ButtonTextTheme.normal;
          break;
        case 'primary':
          result = ButtonTextTheme.primary;
          break;
      }
    }
  }

  return result;
}