change method

dynamic change(
  1. Type toType,
  2. dynamic value
)

Implementation

dynamic change(Type toType, dynamic value) {
  //int asInt({value}) {
  if (toType == int || toType is int) {
    return asInt(value);
  }

  //String asString(value) {
  if (toType == String || toType is String) {
    return value.toString();
  }

  //bool asBool(value) {
  if (toType == bool || toType is bool) {
    return asBool(value);
  }

  //double? asDouble(value) {
  if (toType == double || toType is double) {
    return asDouble(value);
  }

  return null;
}