Do not pad the Input/InputContainer icon (#7282)

This commit is contained in:
Hans Muller 2016-12-16 12:10:57 -08:00 committed by GitHub
parent 895aaa9a2e
commit dbf1cfdbf0
3 changed files with 22 additions and 1 deletions

View File

@ -87,6 +87,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
validator: _validateName,
builder: (FormFieldState<InputValue> field) {
return new Input(
icon: new Icon(Icons.person),
hintText: 'What do people call you?',
labelText: 'Name',
value: field.value,
@ -96,6 +97,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
},
),
new InputFormField(
icon: new Icon(Icons.phone),
hintText: 'Where can we reach you?',
labelText: 'Phone Number',
keyboardType: TextInputType.phone,

View File

@ -358,7 +358,7 @@ class _InputContainerState extends State<InputContainer> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Container(
margin: new EdgeInsets.only(right: 16.0, top: iconTop),
margin: new EdgeInsets.only(top: iconTop),
width: config.isDense ? 40.0 : 48.0,
child: new IconTheme.merge(
context: context,

View File

@ -810,4 +810,23 @@ void main() {
newPos = tester.getTopLeft(find.text('Second'));
expect(newPos.y, lessThan(pos.y));
});
testWidgets('No space between Input icon and text', (WidgetTester tester) async {
await tester.pumpWidget(
new Center(
child: new Material(
child: new Input(
icon: new Icon(Icons.phone),
labelText: 'label',
value: InputValue.empty,
),
),
),
);
final double iconRight = tester.getTopRight(find.byType(Icon)).x;
expect(iconRight, equals(tester.getTopLeft(find.text('label')).x));
expect(iconRight, equals(tester.getTopLeft(find.byType(InputField)).x));
});
}