and 1.0.0 copy "and: ^1.0.0" to clipboard
and: ^1.0.0 copied to clipboard

Join arrays with commas and 'and' before the last item

and #

Join arrays with commas and 'and' before the last item

Usage #

import "package:and/and.dart";

void main() {
  List<String> x = ['1', '2', '3'];

  String simple = and(x); 
  // 1, 2 & 3

  String with_oxford = and(x, oxfordComma: true); 
  // 1, 2, & 3

  String with_separator = and(x, separator: 'and'); 
  // 1, 2 and 3
}

API #

and accepts the one required parameter and two optional ones.

list (required positional parameter) #

List of Strings.

Example: ['1', '2', '3']

separator (optional named parameter) #

The separator to be used for the last item.

Example: and

Default: &

oxfordComma (optional named parameter) #

Use oxford comma in front of the last separator?

Example: true ('1, 2, and 3')

Default: false ('1, 2 and 3')

0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

Join arrays with commas and 'and' before the last item

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on and