CounterStyle.defineCustomAlgorithm constructor
CounterStyle.defineCustomAlgorithm({})
Implementation
factory CounterStyle.defineCustomAlgorithm({
/// The name of the system. Not used internally, but could be used in a
/// list of CounterStyle's to lookup a given style.
required String name,
/// The character to prepend to negative values.
/// If not specified, this system won't use a negative sign
String negative = '',
// TODO add negativeSuffix
/// A prefix to add when generating marker content
String prefix = '',
/// A suffix to add when generating marker content (Defaults to
/// a full stop followed by a space: ". ").
String suffix = '\u002E\u0020',
/// The custom algorithm to apply when generating marker or counter
/// content from this style.
required String Function(int) algorithm,
/// The range of values this CounterStyle can accept. If a counter value is
/// given outside of this range, then the CounterStyle will fall back on
/// the CounterStyle defined by [fallback].
required IntRange range,
/// The length each output must have at minimum, including negative symbols, but not
/// including any suffix or prefix symbols.
/// padLength must be greater than or equal to 0.
int padLength = 0,
/// The character with which to pad the output to reach the given padLength.
/// If more than one character is given in [padCharacter], then the output
/// will be longer than [padLength] (but never shorter).
String padCharacter = '',
/// The CounterStyle to fall back on if the given algorithm can't compute
/// an output or is given out-of-range input.
String fallback = 'decimal',
//TODO speak-as descriptor (https://www.w3.org/TR/css-counter-styles-3/#counter-style-speak-as)
}) {
assert(padLength >= 0);
return CounterStyle._(
name: name,
algorithm: algorithm,
negative: negative,
prefix: prefix,
suffix: suffix,
range: range,
padLength: padLength,
padCharacter: padCharacter,
usesNegative: negative.isNotEmpty,
fallbackStyle: fallback,
);
}