toLiteral function

String toLiteral(
  1. dynamic value
)

Returns the dart literal equivalent to value.

Works with String, int, double, bool, num, null.

Implementation

String toLiteral(dynamic value) {
  if (value is String) {
    return "'${value.replaceAll('\'', '\\\'')}'";
  }

  return value.toString();
}