isEmpty static method

bool isEmpty(
  1. String? str, {
  2. bool emptyValue = false,
})

是否为空

emptyValue true表示空值也是空,false表示空值不认为是空

Examples:

    isEmpty(null);   //true
    isEmpty('');     //true
    isEmpty('   ');  //false
    isEmpty('   ',emptyValue = true);  //true
    isEmpty('null'); //false

Implementation

static bool isEmpty(
  String? str, {
  bool emptyValue = false,
}) {
  if (emptyValue) {
    str = str?.trim();
  }
  return str == null || str.isEmpty;
}