ListFormatter.unitWithLength constructor

ListFormatter.unitWithLength(
  1. Locale locale,
  2. ListLength length
)

Construct a new ListFormatter instance for And patterns from compiled data.

See the Rust documentation for try_new_unit for more information.

Throws DataError on failure.

Implementation

factory ListFormatter.unitWithLength(Locale locale, ListLength length) {
  final result = _icu4x_ListFormatter_create_unit_with_length_mv1(locale._ffi, length.index);
  if (!result.isOk) {
    throw DataError.values[result.union.err];
  }
  return ListFormatter._fromFfi(result.union.ok, []);
}