getPadding method

EdgeInsetsGeometry getPadding(
  1. MaterialButton button

Padding for the button's child (typically the button's label).

Returns the button's MaterialButton.padding if it is non-null, otherwise, returns the padding of the constructor parameter if it is non-null.

Otherwise, returns horizontal padding of 24.0 on the left and right if getTextTheme is ButtonTextTheme.primary, 16.0 on the left and right otherwise.


EdgeInsetsGeometry getPadding(MaterialButton button) {
  if (button.padding != null) {
    return button.padding!;

  if (button is MaterialButtonWithIconMixin) {
    return const EdgeInsetsDirectional.only(start: 12.0, end: 16.0);

  if (_padding != null) {
    return _padding!;

  switch (getTextTheme(button)) {
    case ButtonTextTheme.normal:
    case ButtonTextTheme.accent:
      return const EdgeInsets.symmetric(horizontal: 16.0);
    case ButtonTextTheme.primary:
      return const EdgeInsets.symmetric(horizontal: 24.0);