encloseInParentheses method

  1. @useResult
String? encloseInParentheses({
  1. bool wrapEmpty = false,
})

Returns this string enclosed in parentheses, or null if empty.

When wrapEmpty is true, returns '()' for empty strings.

Implementation

@useResult
String? encloseInParentheses({bool wrapEmpty = false}) {
  if (isEmpty) {
    return wrapEmpty ? '()' : null;
  }

  return '($this)';
}