Commit eed471ea authored by Fredrik Simón's avatar Fredrik Simón Committed by Ian Hickson

Expose textAlign on TextFormField (#13414)

* Expose textAlign on TextFormField

Fixes #11404

* Added name to AUTHORS

* Added a test for TextFormWidget's textAlign
parent 0ca1af7e
......@@ -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,
......
// 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);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment