NumberParserBase<R> class abstract

Constructors

NumberParserBase(NumberFormat format, String text)
Create a new _NumberParser on which we can call parse().

Properties

done bool
Should we stop parsing before hitting the end of the string.
getter/setter pair
format NumberFormat
The format for which we are parsing.
final
gotNegative bool
Did we see something that indicates this is, or at least might be, a negative number.
getter/setter pair
gotNegativeSuffix bool
Did we see the required negative suffix at the end. Should match gotNegative.
getter/setter pair
gotPositive bool
Did we see something that indicates this is, or at least might be, a positive number.
getter/setter pair
gotPositiveSuffix bool
Did we see the required positive suffix at the end. Should match gotPositive.
getter/setter pair
groupingIsNotASpaceOrElseItIsSpaceFollowedByADigit bool
Determine if a space is a valid character in the number. See handleSpace.
no setter
hashCode int
The hash code for this object.
no setterinherited
input → StringStack
What we use to iterate over the input text.
final
prefixesSkipped bool
Have we already skipped over any required prefixes.
getter/setter pair
replacements Map<String, Function>
The strings we might replace with functions that return the replacement values. They are functions because we might need to check something in the context. Note that the ordering is important here. For example, symbols.PERCENT might be " %", and we must handle that before we look at an individual space.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scale int
If the number is percent or permill, what do we divide by at the end.
getter/setter pair
symbols NumberSymbols
The symbols used by our format.
no setter
text String
The text we are parsing.
final
value ↔ R?
The result of parsing text according to format. Automatically populated in the constructor.
getter/setter pair

Methods

asDigit(String char) int?
Turn char into a number representing a digit, or null if it doesn't represent a digit in this locale.
checkPrefixes({bool skip = false}) → void
Check to see if the input begins with either the positive or negative prefixes. Set the gotPositive and gotNegative variables accordingly.
checkSuffixes() → void
If the rest of our input is either the positive or negative suffix, set gotPositiveSuffix or gotNegativeSuffix accordingly.
fromNormalized(String normalizedText) → R
handleSpace() → void
Replace a space in the number with the normalized form. If space is not a significant character (normally grouping) then it's just invalid. If it is the grouping character, then it's only valid if it's followed by a digit. e.g. '$12 345.00'
invalidFormat() → void
invalidNumber() → void
The number is invalid, throw a FormatException.
nan() → R
negativeInfinity() → R
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse() → R
Parse text and return the resulting number. Throws FormatException if we can't parse it.
parseNumber(StringStack input) → R
Parse the number portion of the input, i.e. not any prefixes or suffixes, and assuming NaN and Infinity are already handled.
positiveInfinity() → R
processNonDigit() → void
We've encountered a character that's not a digit. Go through our replacement rules looking for how to handle it. If we see something that's not a digit and doesn't have a replacement, then we're done and the number is probably invalid.
scaled(R parsed, int scale) → R
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited