getPadding method

EdgeInsetsGeometry getPadding (MaterialButton button)

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

Returns the button's MaterialButton.padding if it is non-null.

If this is a button constructed with RaisedButton.icon or FlatButton.icon or OutlineButton.icon then the padding is: EdgeInsetsDirectional.only(start: 12.0, end: 16.0).

Otherwise, returns padding 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.

Implementation

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);
  }
  assert(false);
  return EdgeInsets.zero;
}