getElevation method Null safety

double getElevation(
  1. MaterialButton button

The button's elevation when it is enabled and has not been pressed.

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

If button is a FlatButton then elevation is 0.0, otherwise it is 2.0.


double getElevation(MaterialButton button) {
  if (button.elevation != null)
    return button.elevation!;
  if (button is FlatButton)
    return 0.0;
  return 2.0;