InputDecorationTheme.isCollapsed
doesn't work if InputDecoration.isCollapsed
is not provided. (#133189)
`appleDefault` method didn't include setting values for non-null (here `isCollapsed`) parameters initially, which has been updated and documented in this commit. Existing and new tests are passing. Fixes #133144
This commit is contained in:
parent
9e9aa810be
commit
dd1ee24fc2
@ -2169,7 +2169,10 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
return border.copyWith(
|
||||
borderSide: BorderSide(
|
||||
color: _getDefaultM2BorderColor(themeData),
|
||||
width: (decoration.isCollapsed || decoration.border == InputBorder.none || !decoration.enabled)
|
||||
width: (
|
||||
(decoration.isCollapsed ?? themeData.inputDecorationTheme.isCollapsed)
|
||||
|| decoration.border == InputBorder.none
|
||||
|| !decoration.enabled)
|
||||
? 0.0
|
||||
: isFocused ? 2.0 : 1.0,
|
||||
),
|
||||
@ -2402,7 +2405,8 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
|
||||
final EdgeInsets contentPadding;
|
||||
final double floatingLabelHeight;
|
||||
if (decoration.isCollapsed) {
|
||||
if (decoration.isCollapsed
|
||||
?? themeData.inputDecorationTheme.isCollapsed) {
|
||||
floatingLabelHeight = 0.0;
|
||||
contentPadding = decorationContentPadding ?? EdgeInsets.zero;
|
||||
} else if (!border.isOutline) {
|
||||
@ -2430,7 +2434,7 @@ class _InputDecoratorState extends State<InputDecorator> with TickerProviderStat
|
||||
final _Decorator decorator = _Decorator(
|
||||
decoration: _Decoration(
|
||||
contentPadding: contentPadding,
|
||||
isCollapsed: decoration.isCollapsed,
|
||||
isCollapsed: decoration.isCollapsed ?? themeData.inputDecorationTheme.isCollapsed,
|
||||
floatingLabelHeight: floatingLabelHeight,
|
||||
floatingLabelAlignment: decoration.floatingLabelAlignment!,
|
||||
floatingLabelProgress: _floatingLabelAnimation.value,
|
||||
@ -2577,7 +2581,7 @@ class InputDecoration {
|
||||
this.errorMaxLines,
|
||||
this.floatingLabelBehavior,
|
||||
this.floatingLabelAlignment,
|
||||
this.isCollapsed = false,
|
||||
this.isCollapsed,
|
||||
this.isDense,
|
||||
this.contentPadding,
|
||||
this.prefixIcon,
|
||||
@ -2976,7 +2980,7 @@ class InputDecoration {
|
||||
/// A collapsed decoration cannot have [labelText], [errorText], an [icon].
|
||||
///
|
||||
/// To create a collapsed input decoration, use [InputDecoration.collapsed].
|
||||
final bool isCollapsed;
|
||||
final bool? isCollapsed;
|
||||
|
||||
/// An icon that appears before the [prefix] or [prefixText] and before
|
||||
/// the editable part of the text field, within the decoration's container.
|
||||
@ -3620,7 +3624,7 @@ class InputDecoration {
|
||||
floatingLabelAlignment: floatingLabelAlignment ?? theme.floatingLabelAlignment,
|
||||
isDense: isDense ?? theme.isDense,
|
||||
contentPadding: contentPadding ?? theme.contentPadding,
|
||||
isCollapsed: isCollapsed,
|
||||
isCollapsed: isCollapsed ?? theme.isCollapsed,
|
||||
iconColor: iconColor ?? theme.iconColor,
|
||||
prefixStyle: prefixStyle ?? theme.prefixStyle,
|
||||
prefixIconColor: prefixIconColor ?? theme.prefixIconColor,
|
||||
@ -3782,7 +3786,7 @@ class InputDecoration {
|
||||
if (floatingLabelAlignment != null) 'floatingLabelAlignment: $floatingLabelAlignment',
|
||||
if (isDense ?? false) 'isDense: $isDense',
|
||||
if (contentPadding != null) 'contentPadding: $contentPadding',
|
||||
if (isCollapsed) 'isCollapsed: $isCollapsed',
|
||||
if (isCollapsed ?? false) 'isCollapsed: $isCollapsed',
|
||||
if (prefixIcon != null) 'prefixIcon: $prefixIcon',
|
||||
if (prefixIconColor != null) 'prefixIconColor: $prefixIconColor',
|
||||
if (prefix != null) 'prefix: $prefix',
|
||||
|
@ -6570,4 +6570,25 @@ testWidgets('OutlineInputBorder with BorderRadius.zero should draw a rectangular
|
||||
expect(find.byType(InputDecorator), findsOneWidget);
|
||||
expect(tester.renderObject<RenderBox>(find.text('COUNTER')).size, Size.zero);
|
||||
});
|
||||
|
||||
group('isCollapsed parameter works with themeData', () {
|
||||
test('parameter is provided in InputDecorationTheme', () {
|
||||
final InputDecoration decoration = const InputDecoration(
|
||||
hintText: 'Hello, Flutter!',
|
||||
).applyDefaults(const InputDecorationTheme(
|
||||
isCollapsed: true,
|
||||
));
|
||||
|
||||
expect(decoration.isCollapsed, true);
|
||||
});
|
||||
|
||||
test('parameter is provided in InputDecoration', () {
|
||||
final InputDecoration decoration = const InputDecoration(
|
||||
isCollapsed: true,
|
||||
hintText: 'Hello, Flutter!',
|
||||
).applyDefaults(const InputDecorationTheme());
|
||||
|
||||
expect(decoration.isCollapsed, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user