Expose textAlign on TextFormField (#13414)
* Expose textAlign on TextFormField
Fixes #11404
* Added name to AUTHORS
* Added a test for TextFormWidget's textAlign
diff --git a/AUTHORS b/AUTHORS
index d7e59a9..3501c54 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -18,3 +18,4 @@
German Saprykin <saprykin.h@gmail.com>
Stefano Rodriguez <hlsroddy@gmail.com>
Yusuke Konishi <yahpeycoy0403@gmail.com>
+Fredrik Simón <fredrik@fsimon.net>
diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart
index a8ac00e..df6e85e 100644
--- a/packages/flutter/lib/src/material/text_form_field.dart
+++ b/packages/flutter/lib/src/material/text_form_field.dart
@@ -48,6 +48,7 @@
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 @@
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 @@
decoration: decoration.copyWith(errorText: field.errorText),
keyboardType: keyboardType,
style: style,
+ textAlign: textAlign,
autofocus: autofocus,
obscureText: obscureText,
autocorrect: autocorrect,
diff --git a/packages/flutter/test/material/text_form_field_test.dart b/packages/flutter/test/material/text_form_field_test.dart
new file mode 100644
index 0000000..871e8b9
--- /dev/null
+++ b/packages/flutter/test/material/text_form_field_test.dart
@@ -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);
+ });
+}