Expose textAlign on TextFormField (#13414)
* Expose textAlign on TextFormField Fixes #11404 * Added name to AUTHORS * Added a test for TextFormWidget's textAlign
This commit is contained in:
parent
0ca1af7e4f
commit
eed471ea3d
1
AUTHORS
1
AUTHORS
@ -18,3 +18,4 @@ Mike Hoolehan <mike@hoolehan.com>
|
||||
German Saprykin <saprykin.h@gmail.com>
|
||||
Stefano Rodriguez <hlsroddy@gmail.com>
|
||||
Yusuke Konishi <yahpeycoy0403@gmail.com>
|
||||
Fredrik Simón <fredrik@fsimon.net>
|
||||
|
@ -48,6 +48,7 @@ class TextFormField extends FormField<String> {
|
||||
InputDecoration decoration: const InputDecoration(),
|
||||
TextInputType keyboardType: TextInputType.text,
|
||||
TextStyle style,
|
||||
TextAlign textAlign: TextAlign.start,
|
||||
bool autofocus: false,
|
||||
bool obscureText: false,
|
||||
bool autocorrect: true,
|
||||
@ -57,6 +58,7 @@ class TextFormField extends FormField<String> {
|
||||
List<TextInputFormatter> inputFormatters,
|
||||
}) : assert(initialValue != null),
|
||||
assert(keyboardType != null),
|
||||
assert(textAlign != null),
|
||||
assert(autofocus != null),
|
||||
assert(obscureText != null),
|
||||
assert(autocorrect != null),
|
||||
@ -74,6 +76,7 @@ class TextFormField extends FormField<String> {
|
||||
decoration: decoration.copyWith(errorText: field.errorText),
|
||||
keyboardType: keyboardType,
|
||||
style: style,
|
||||
textAlign: textAlign,
|
||||
autofocus: autofocus,
|
||||
obscureText: obscureText,
|
||||
autocorrect: autocorrect,
|
||||
|
30
packages/flutter/test/material/text_form_field_test.dart
Normal file
30
packages/flutter/test/material/text_form_field_test.dart
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Passes textAlign to underlying TextField', (WidgetTester tester) async {
|
||||
const TextAlign alignment = TextAlign.center;
|
||||
|
||||
await tester.pumpWidget(
|
||||
new MaterialApp(
|
||||
home: new Material(
|
||||
child: new Center(
|
||||
child: new TextFormField(
|
||||
textAlign: alignment,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final Finder textFieldFinder = find.byType(TextField);
|
||||
expect(textFieldFinder, findsOneWidget);
|
||||
|
||||
final TextField textFieldWidget = tester.widget(textFieldFinder);
|
||||
expect(textFieldWidget.textAlign, alignment);
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user