stringValue property

  1. @override
String stringValue
override

Converts the value into a string value and returns the result.

Implementation

@override
String get stringValue {
  final t = _value.runtimeType;
  if (_stringify != null) {
    return _stringify.call(_value);
  } else if (t == String) {
    return _value as String;
  } else if (t == bool) {
    return (_value as bool) ? 'true' : 'false';
  } else if (t == int || t == double) {
    return _value.toString();
  } else {
    throw ArgumentError(
        'Missing "toString" method for unknown type "${T.toString()}".');
  }
}
void stringValue=(String str)

Parses str and writes the result into value.

Implementation

set stringValue(String str) {
  final t = _value.runtimeType;

  if (_parse != null) {
    value = _parse.call(str);
  } else if (t == int) {
    value = int.parse(str) as T;
  } else if (t == double) {
    value = double.parse(str) as T;
  } else if (t == bool) {
    switch (str.toLowerCase()) {
      case 'false':
      case '0':
      case 'no':
        value = false as T;
        break;
      case 'true':
      case '1':
      case 'yes':
        value = true as T;
    }
  } else if (t == String) {
    value = str as T;
  } else {
    throw ArgumentError('Missing "parse" method for type "${T.toString()}".');
  }
}