formatProductBrands function

String formatProductBrands(
  1. String brands, {
  2. String separator = ', ',
})

Correctly format word separators between words.

Implementation

String formatProductBrands(String brands, {String separator = ', '}) {
  final String separatorChar = RegExp.escape(',');
  final RegExp regex = RegExp('\\s*$separatorChar\\s*');
  return brands.replaceAll(regex, separator);
}