asString method

String asString({
  1. String? def,
  2. bool trim = true,
})

Implementation

String asString({String? def, bool trim = true}) {
  def ??= '';
  var res = (this ?? def).toString();
  if (trim) {
    res = res.trim();
  }
  return res.isEmpty ? def : res;
}