wrapWith method

  1. @useResult
String? wrapWith({
  1. String? before,
  2. String? after,
})

Returns this string wrapped with before prepended and after appended, or null if the string is empty. Audited: 2026-06-12 11:26 EDT

Implementation

@useResult
String? wrapWith({String? before, String? after}) {
  if (isEmpty) {
    return null;
  }

  return '${before ?? ''}$this${after ?? ''}';
}