From e8168401e57fbe010fc581e48ff42b00e6dee0cf Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Thu, 13 Oct 2016 18:15:59 -0400 Subject: [PATCH] Stop fields moving when focus changes (#6316) Previously, if you focused a field, fields below it would shift down by one pixel. This change tries to guarantee that that won't happen. --- packages/flutter/lib/src/material/input.dart | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/flutter/lib/src/material/input.dart b/packages/flutter/lib/src/material/input.dart index 2c24270ed3f..8c0c7f6abf7 100644 --- a/packages/flutter/lib/src/material/input.dart +++ b/packages/flutter/lib/src/material/input.dart @@ -177,32 +177,34 @@ class _InputState extends State { )); } - EdgeInsets margin = new EdgeInsets.only(bottom: config.isDense ? 4.0 : 8.0); - EdgeInsets padding = new EdgeInsets.only(top: topPadding, bottom: 8.0); Color borderColor = activeColor; - double borderWidth = focused ? 2.0 : 1.0; + double bottomPadding = 8.0; + double bottomBorder = focused ? 2.0 : 1.0; + double bottomHeight = config.isDense ? 14.0 : 18.0; if (errorText != null) { borderColor = themeData.errorColor; - borderWidth = 2.0; - if (!config.isDense) { - margin = const EdgeInsets.only(bottom: 15.0); - padding = new EdgeInsets.only(top: topPadding, bottom: 1.0); - } + 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( + color: borderColor, + width: bottomBorder, + ) + ); + EdgeInsets margin = new EdgeInsets.only(bottom: bottomHeight - (bottomPadding + bottomBorder)); + stackChildren.add(new AnimatedContainer( margin: margin, padding: padding, duration: _kTransitionDuration, curve: _kTransitionCurve, decoration: new BoxDecoration( - border: new Border( - bottom: new BorderSide( - color: borderColor, - width: borderWidth - ) - ) + border: border, ), child: new RawInputLine( key: _rawInputLineKey,