Skip to content

Commit d10140a

Browse files
committed
compose [nfc]: Make maxLengthUnicodeCodePoints nullable.
This will allow controller implementations that do not support validation errors akin to "*TooLong" to set this to null.
1 parent 943f3ac commit d10140a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/widgets/compose_box.dart

+5-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const double _composeButtonSize = 44;
8181
///
8282
/// Subclasses must ensure that [_update] is called in all exposed constructors.
8383
abstract class ComposeController<ErrorT> extends TextEditingController {
84-
int get maxLengthUnicodeCodePoints;
84+
int? get maxLengthUnicodeCodePoints;
8585

8686
String get textNormalized => _textNormalized;
8787
late String _textNormalized;
@@ -102,7 +102,8 @@ abstract class ComposeController<ErrorT> extends TextEditingController {
102102
@visibleForTesting
103103
int? get debugLengthUnicodeCodePointsIfLong => _lengthUnicodeCodePointsIfLong;
104104
int? _computeLengthUnicodeCodePointsIfLong() =>
105-
_textNormalized.length > maxLengthUnicodeCodePoints
105+
maxLengthUnicodeCodePoints != null
106+
&& _textNormalized.length > maxLengthUnicodeCodePoints!
106107
? _textNormalized.runes.length
107108
: null;
108109

@@ -152,7 +153,7 @@ class ComposeTopicController extends ComposeController<TopicValidationError> {
152153
bool get mandatory => store.realmMandatoryTopics;
153154

154155
// TODO(#307) use `max_topic_length` instead of hardcoded limit
155-
@override final maxLengthUnicodeCodePoints = kMaxTopicLengthCodePoints;
156+
@override final int maxLengthUnicodeCodePoints = kMaxTopicLengthCodePoints;
156157

157158
@override
158159
String _computeTextNormalized() {
@@ -213,7 +214,7 @@ class ComposeContentController extends ComposeController<ContentValidationError>
213214
}
214215

215216
// TODO(#1237) use `max_message_length` instead of hardcoded limit
216-
@override final maxLengthUnicodeCodePoints = kMaxMessageLengthCodePoints;
217+
@override final int maxLengthUnicodeCodePoints = kMaxMessageLengthCodePoints;
217218

218219
int _nextQuoteAndReplyTag = 0;
219220
int _nextUploadTag = 0;

0 commit comments

Comments
 (0)