Skip to content

Commit

Permalink
Always reserve space for error text in text fields. (flutter#7206)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpcomplete authored Dec 12, 2016
1 parent 25e6cc6 commit 5a864de
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions packages/flutter/lib/src/material/input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,11 @@ class _InputContainerState extends State<InputContainer> {
);
}

Color borderColor = activeColor;
double bottomPadding = 8.0;
double bottomBorder = config.focused ? 2.0 : 1.0;
Color borderColor = errorText == null ? activeColor : themeData.errorColor;
double bottomPadding = config.isDense ? 8.0 : 1.0;
double bottomBorder = 2.0;
double bottomHeight = config.isDense ? 14.0 : 18.0;

if (errorText != null) {
borderColor = themeData.errorColor;
bottomBorder = 2.0;
if (!config.isDense)
bottomPadding = 1.0;
}

EdgeInsets padding = new EdgeInsets.only(top: topPadding, bottom: bottomPadding);
Border border = new Border(
bottom: new BorderSide(
Expand Down Expand Up @@ -334,12 +327,12 @@ class _InputContainerState extends State<InputContainer> {
}
stackChildren.add(divider);

if (errorText != null && !config.isDense) {
if (!config.isDense) {
TextStyle errorStyle = themeData.textTheme.caption.copyWith(color: themeData.errorColor);
stackChildren.add(new Positioned(
left: 0.0,
bottom: 0.0,
child: new Text(errorText, style: errorStyle)
child: new Text(errorText ?? '', style: errorStyle)
));
}

Expand Down Expand Up @@ -450,6 +443,7 @@ class Input extends StatefulWidget {
final bool hideDivider;

/// Whether the input field is part of a dense form (i.e., uses less vertical space).
/// If true, [errorText] is not shown.
final bool isDense;

/// Whether this input field should focus itself if nothing else is already focused.
Expand Down

0 comments on commit 5a864de

Please sign in to comment.