Skip to content

Commit 6067b30

Browse files
committed
Fix Input padding to match the material spec
Also, handle the case of "dense" input widgets that have less margin. Fixes flutter#626
1 parent 6fbe39e commit 6067b30

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

‎packages/flutter/lib/src/material/input.dart‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ import 'theme.dart';
1212
export 'package:flutter/rendering.dart' show ValueChanged;
1313
export 'package:flutter/services.dart' show KeyboardType;
1414

15-
// TODO(eseidel): This isn't right, it's 16px on the bottom:
16-
// http://www.google.com/design/spec/components/text-fields.html#text-fields-single-line-text-field
17-
const EdgeDims _kTextfieldPadding = const EdgeDims.symmetric(vertical: 8.0);
18-
1915
class Input extends Scrollable {
2016
Input({
2117
GlobalKey key,
2218
this.initialValue: '',
2319
this.placeholder,
2420
this.hideText: false,
21+
this.isDense: false,
2522
this.onChanged,
2623
this.keyboardType: KeyboardType.TEXT,
2724
this.onSubmitted
@@ -35,6 +32,7 @@ class Input extends Scrollable {
3532
final KeyboardType keyboardType;
3633
final String placeholder;
3734
final bool hideText;
35+
final bool isDense;
3836
final ValueChanged<String> onChanged;
3937
final ValueChanged<String> onSubmitted;
4038

@@ -123,15 +121,21 @@ class InputState extends ScrollableState<Input> {
123121
onSizeChanged: _handleContainerSizeChanged,
124122
child: new Container(
125123
child: new Stack(textChildren),
126-
padding: _kTextfieldPadding,
127-
decoration: new BoxDecoration(border: new Border(
128-
bottom: new BorderSide(
129-
color: focusHighlightColor,
130-
width: focused ? 2.0 : 1.0
124+
margin: config.isDense ?
125+
const EdgeDims.symmetric(vertical: 4.0) :
126+
const EdgeDims.symmetric(vertical: 8.0),
127+
padding: const EdgeDims.symmetric(vertical: 8.0),
128+
decoration: new BoxDecoration(
129+
border: new Border(
130+
bottom: new BorderSide(
131+
color: focusHighlightColor,
132+
width: focused ? 2.0 : 1.0
133+
)
131134
)
132-
))
135+
)
133136
)
134137
),
138+
behavior: HitTestBehavior.opaque,
135139
onPointerDown: (_) {
136140
// TODO(ianh): https://github.com/flutter/engine/issues/1530
137141
if (Focus.at(context, config)) {

0 commit comments

Comments
 (0)