applyDefaults method
- Object inputDecorationTheme
Used by widgets like TextField and InputDecorator to create a new
InputDecoration with default values taken from the inputDecorationTheme
.
Only null valued properties from this InputDecoration are replaced
by the corresponding values from inputDecorationTheme
.
Implementation
InputDecoration applyDefaults(Object inputDecorationTheme) {
// TODO(bleroux): Clean this up once the type of `inputDecorationTheme` is changed to `InputDecorationThemeData`
if (inputDecorationTheme is! InputDecorationTheme &&
inputDecorationTheme is! InputDecorationThemeData) {
throw ArgumentError(
'inputDecorationTheme must be either a InputDecorationThemeData or a InputDecorationTheme',
);
}
final InputDecorationThemeData theme = (inputDecorationTheme is InputDecorationTheme)
? inputDecorationTheme.data
: inputDecorationTheme as InputDecorationThemeData;
return copyWith(
labelStyle: labelStyle ?? theme.labelStyle,
floatingLabelStyle: floatingLabelStyle ?? theme.floatingLabelStyle,
helperStyle: helperStyle ?? theme.helperStyle,
helperMaxLines: helperMaxLines ?? theme.helperMaxLines,
hintStyle: hintStyle ?? theme.hintStyle,
hintFadeDuration: hintFadeDuration ?? theme.hintFadeDuration,
hintMaxLines: hintMaxLines ?? theme.hintMaxLines,
errorStyle: errorStyle ?? theme.errorStyle,
errorMaxLines: errorMaxLines ?? theme.errorMaxLines,
floatingLabelBehavior: floatingLabelBehavior ?? theme.floatingLabelBehavior,
floatingLabelAlignment: floatingLabelAlignment ?? theme.floatingLabelAlignment,
isDense: isDense ?? theme.isDense,
contentPadding: contentPadding ?? theme.contentPadding,
isCollapsed: isCollapsed ?? theme.isCollapsed,
iconColor: iconColor ?? theme.iconColor,
prefixStyle: prefixStyle ?? theme.prefixStyle,
prefixIconColor: prefixIconColor ?? theme.prefixIconColor,
prefixIconConstraints: prefixIconConstraints ?? theme.prefixIconConstraints,
suffixStyle: suffixStyle ?? theme.suffixStyle,
suffixIconColor: suffixIconColor ?? theme.suffixIconColor,
suffixIconConstraints: suffixIconConstraints ?? theme.suffixIconConstraints,
counterStyle: counterStyle ?? theme.counterStyle,
filled: filled ?? theme.filled,
fillColor: fillColor ?? theme.fillColor,
focusColor: focusColor ?? theme.focusColor,
hoverColor: hoverColor ?? theme.hoverColor,
errorBorder: errorBorder ?? theme.errorBorder,
focusedBorder: focusedBorder ?? theme.focusedBorder,
focusedErrorBorder: focusedErrorBorder ?? theme.focusedErrorBorder,
disabledBorder: disabledBorder ?? theme.disabledBorder,
enabledBorder: enabledBorder ?? theme.enabledBorder,
border: border ?? theme.border,
alignLabelWithHint: alignLabelWithHint ?? theme.alignLabelWithHint,
constraints: constraints ?? theme.constraints,
visualDensity: visualDensity ?? theme.visualDensity,
);
}