Sayegh7 / and

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

Home Page:https://pub.dev/packages/and

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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')

About

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

https://pub.dev/packages/and

License:MIT License


Languages

Language:Dart 100.0%