Unverified Commit 533c6b29 authored by Justin McCandless's avatar Justin McCandless Committed by GitHub

Show hint when label is floating (#60394)

parent e3ad0345
......@@ -2086,9 +2086,14 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
}
// True if the label will be shown and the hint will not.
// If we're not focused, there's no value, and labelText was provided,
// then the label appears where the hint would.
bool get _hasInlineLabel => !widget._labelShouldWithdraw && decoration.labelText != null;
// If we're not focused, there's no value, labelText was provided, and
// floatingLabelBehavior isn't set to always, then the label appears where the
// hint would.
bool get _hasInlineLabel {
return !widget._labelShouldWithdraw
&& decoration.labelText != null
&& decoration.floatingLabelBehavior != FloatingLabelBehavior.always;
}
// If the label is a floating placeholder, it's always shown.
bool get _shouldShowLabel => _hasInlineLabel || _floatingLabelEnabled;
......
......@@ -4068,6 +4068,23 @@ void main() {
expect(tester.getTopLeft(find.text('label')).dy, 20.0);
});
testWidgets('InputDecorator hint is displayed when floatingLabelBehavior is always', (WidgetTester tester) async {
await tester.pumpWidget(
buildInputDecorator(
// isFocused: false (default)
isEmpty: true,
decoration: const InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.always,
hintText: 'hint',
labelText: 'label',
),
),
);
await tester.pumpAndSettle();
expect(getOpacity(tester, 'hint'), 1.0);
});
testWidgets('InputDecorator floating label width scales when focused', (WidgetTester tester) async {
final String longStringA = String.fromCharCodes(List<int>.generate(200, (_) => 65));
final String longStringB = String.fromCharCodes(List<int>.generate(200, (_) => 66));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment