diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index d34d84f58c..4b4e44fab1 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -834,6 +834,17 @@ class _RenderDecoration extends RenderBox { // This method applies layout to all of the renderers except the container. // For convenience, the container is laid out in performLayout(). _RenderDecorationLayout _layout(BoxConstraints layoutConstraints) { + assert( + layoutConstraints.maxWidth < double.infinity, + 'An InputDecorator, which is typically created by a TextField, cannot ' + 'have an unbounded width.\n' + 'This happens when the parent widget does not provide a finite width ' + 'constraint. For example, if the InputDecorator is contained by a Row, ' + 'then its width must be constrained. An Expanded widget or a SizedBox ' + 'can be used to constrain the width of the InputDecorator or the ' + 'TextField that contains it.', + ); + // Margin on each side of subtext (counter and helperError) final Map boxToBaseline = {}; final BoxConstraints boxConstraints = layoutConstraints.loosen();