buildTextButton method

Widget buildTextButton()

Implementation

Widget buildTextButton() {
  return ElevatedButton(
    style: ButtonStyle(
      padding: MaterialStateProperty.all(EdgeInsets.zero),
      shadowColor: MaterialStateProperty.resolveWith(
        (states) {
          return Colors.transparent;
        },
      ),
      foregroundColor: MaterialStateProperty.resolveWith(
        (states) {
          if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) {
            //获取焦点和按下时的颜色
            return pressedBackgroundColor;
          }
          //默认状态使用的颜色
          return Colors.transparent;
        },
      ),

      backgroundColor: MaterialStateProperty.resolveWith((states) {
        //设置按下时的背景颜色
        if (states.contains(MaterialState.focused) || states.contains(MaterialState.pressed)) {
          return pressedBackgroundColor;
        } else {
          return Colors.transparent;
        }
      }),
      elevation: MaterialStateProperty.all(0),
      //设置按钮的最小尺寸
      //minimumSize: MaterialStateProperty.all(size),
      //外边框装饰
      shape: MaterialStateProperty.all(outlinedBorder),
    ),
    child: Text(
      text,
      textAlign: TextAlign.center,
      style: TextStyle(
        color: textColor,
        fontSize: fontSize,
        fontWeight: fontWeight,
      ),
    ),
    onPressed: () {
      onClick();
    },
  );
}