customFlatButton static method

Widget customFlatButton(
  1. String title,
  2. Color bgColor,
  3. Function onPressed, [
  4. dynamic isIconButton = false,
  5. IconData icon = Icons.check_circle,
  6. Color textColor = Colors.white,
])

Implementation

static Widget customFlatButton(
    String title, Color bgColor, Function onPressed,
    [isIconButton = false,
    IconData icon = Icons.check_circle,
    Color textColor = Colors.white]) {
  return !isIconButton
      ? TextButton(
          style: ButtonStyle(
              backgroundColor: MaterialStateProperty.all(bgColor)),
          onPressed: onPressed as void Function()?,
          child: Text(
            title,
            style: const TextStyle(color: Colors.white),
          ),
        )
      : TextButton.icon(
          style: ButtonStyle(
              backgroundColor: MaterialStateProperty.all(bgColor)),
          onPressed: onPressed as void Function()?,
          icon: Icon(
            icon,
            color: textColor,
          ),
          label: Text(
            title,
            style: TextStyle(color: textColor),
          ));
}