Update text_form_field.dart (#81043)

This commit is contained in:
Guilherme Henrique
2021-05-02 01:29:03 -03:00
committed by GitHub
parent ec91c6582b
commit 741bb9d329
2 changed files with 14 additions and 1 deletions

View File

@@ -228,7 +228,7 @@ class TextFormField extends FormField<String> {
'minLines and maxLines must be null when expands is true.',
),
assert(!obscureText || maxLines == 1, 'Obscured fields cannot be multiline.'),
assert(maxLength == null || maxLength > 0),
assert(maxLength == null || maxLength == TextField.noMaxLength || maxLength > 0),
assert(enableInteractiveSelection != null),
super(
key: key,

View File

@@ -114,6 +114,19 @@ void main() {
expect(find.byType(CupertinoButton), findsNothing);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.macOS, TargetPlatform.windows, TargetPlatform.linux }), skip: kIsWeb);
testWidgets('TextFormField accepts TextField.noMaxLength as value to maxLength parameter', (WidgetTester tester) async {
bool asserted;
try {
TextFormField(
maxLength: TextField.noMaxLength,
);
asserted = false;
} catch (e){
asserted = true;
}
expect(asserted, false);
});
testWidgets('Passes textAlign to underlying TextField', (WidgetTester tester) async {
const TextAlign alignment = TextAlign.center;