checkStringWithoutSpace static method

String? checkStringWithoutSpace(
  1. String? text
)

This function checks if the given text is not null, not empty, and does not contain spaces. Returns the text if it meets the conditions, otherwise returns null. Example: checkStringWithoutSpace("Hello World") returns null.

Implementation

static String? checkStringWithoutSpace(String? text) {
  if (text == null || text.trim().isEmpty || text.contains(' ')) {
    return null;
  }
  return text;
}