encloseInSingleQuotes property

bool get encloseInSingleQuotes

Implementation

bool get encloseInSingleQuotes {
  if (alwaysEncloseInSingleQuotes) return true;

  // If there is an empty string value, then it must be enclosed
  // in single quotes and therefore all other values should be
  // enclosed as well.
  if (contains("")) return true;

  // A number that starts with 0, but not only '0'
  if (indexWhere((e) => null != e && e.length > 1 && e.startsWith("0")) >=
      0) {
    return true;
  }

  // Anything other than numbers
  final nonNumberRegex = RegExp(r"[^\d]+");
  if (indexWhere((e) => null != e && nonNumberRegex.hasMatch(e)) >= 0) {
    return true;
  }

  return false;
}