diff --git a/lib/src/mask_parser_iterator.dart b/lib/src/mask_parser_iterator.dart index 368d51b..bde998c 100644 --- a/lib/src/mask_parser_iterator.dart +++ b/lib/src/mask_parser_iterator.dart @@ -66,7 +66,7 @@ extension NumberFormatPartExt on String { result.add(StaticPart(content)); content = ''; } - result.add(CurrencySignPart(currencySign)); + result.add(StaticPart(currencySign)); } else { content += char; } diff --git a/lib/src/part_length.dart b/lib/src/part_length.dart deleted file mode 100644 index 93de55e..0000000 --- a/lib/src/part_length.dart +++ /dev/null @@ -1,32 +0,0 @@ -/// Describes the length constraints of a number format part. -abstract class PartLength {} - -/// A fixed-length part. -class DeterminedPartLength extends PartLength { - /// The exact length of this part. - final int length; - - /// Creates a fixed-length constraint of [length]. - DeterminedPartLength(this.length); -} - -/// A variable-length part with minimum and maximum bounds. -class VariablePartLength extends PartLength { - /// The minimum length of this part. - final int min; - - /// The maximum length of this part. - final int max; - - /// Creates a variable-length constraint between [min] and [max]. - VariablePartLength(this.min, this.max); -} - -/// A part with a minimum length and no upper bound. -class AtLeastPartLength extends PartLength { - /// The minimum length of this part. - final int min; - - /// Creates a minimum-length constraint of [min]. - AtLeastPartLength(this.min); -} diff --git a/lib/src/parts.dart b/lib/src/parts.dart index bf83f5a..0f29ade 100644 --- a/lib/src/parts.dart +++ b/lib/src/parts.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:number_editing_controller/src/grouping.dart'; -import 'package:number_editing_controller/src/part_length.dart'; /// The result of formatting a single [NumberFormatPart]. class PartFormatResult { @@ -36,9 +35,6 @@ class PartFormatResult { /// A segment of a number format pattern that knows how to format its portion of input. abstract class NumberFormatPart { - /// The length constraints of this part. - PartLength get length; - /// Formats the input [value] starting at [position] and returns the result. PartFormatResult format(TextEditingValue value, int position); } @@ -48,9 +44,6 @@ class StaticPart extends NumberFormatPart { /// The static text content. final String content; - @override - PartLength get length => DeterminedPartLength(content.length); - StaticPart(this.content); @override @@ -84,12 +77,6 @@ class StaticPart extends NumberFormatPart { } } -/// A [StaticPart] that represents a currency symbol. -class CurrencySignPart extends StaticPart { - /// Creates a currency sign part with the given symbol [content]. - CurrencySignPart(super.content); -} - /// A part that represents the integer portion of a number. class RealPart extends NumberFormatPart { /// The digit grouping configuration. @@ -101,9 +88,6 @@ class RealPart extends NumberFormatPart { /// Creates a [RealPart] with the given [grouping] and [allowNegative] flag. RealPart(this.grouping, this.allowNegative); - @override - PartLength get length => AtLeastPartLength(1); - @override PartFormatResult format(TextEditingValue value, int position) { var i = 0; @@ -204,24 +188,6 @@ class DecimalPart extends NumberFormatPart { /// Creates a [DecimalPart] with the given length bounds and [decimalSeparator]. DecimalPart(this.minLength, this.maxLength, this.decimalSeparator); - @override - PartLength get length { - if (minLength == 0 && maxLength == 0) { - return DeterminedPartLength(0); - } - if (minLength == 0 && maxLength != 0) { - return VariablePartLength( - 0, - maxLength + decimalSeparator.length, - ); - } - - return VariablePartLength( - minLength + decimalSeparator.length, - maxLength + decimalSeparator.length, - ); - } - @override PartFormatResult format(TextEditingValue value, int position) { var i = 0;