button property

  1. @override
BeautifulPopupButton get button
override

Implementation

@override
BeautifulPopupButton get button {
  return ({
    required String label,
    required void Function() onPressed,
    bool outline = false,
    bool flat = false,
    TextStyle labelStyle = const TextStyle(),
  }) {
    final gradient = LinearGradient(colors: [
      primaryColor.withOpacity(0.5),
      primaryColor,
    ]);
    final double elevation = (outline || flat) ? 0 : 2;
    final labelColor =
        (outline || flat) ? primaryColor : Colors.white.withOpacity(0.95);
    final decoration = BoxDecoration(
      gradient: (outline || flat) ? null : gradient,
      borderRadius: BorderRadius.all(Radius.circular(80.0)),
      border: Border.all(
        color: outline ? primaryColor : Colors.transparent,
        width: (outline && !flat) ? 1 : 0,
      ),
    );
    final minHeight = 40.0 - (outline ? 4 : 0);
    return RaisedButton(
      color: Colors.transparent,
      elevation: elevation,
      highlightElevation: 0,
      splashColor: Colors.transparent,
      child: Ink(
        decoration: decoration,
        child: Container(
          constraints: BoxConstraints(
            minWidth: 100,
            minHeight: minHeight,
          ),
          alignment: Alignment.center,
          child: Text(
            label,
            style: TextStyle(
              color: Colors.white.withOpacity(0.95),
              fontWeight: FontWeight.bold,
            ).merge(labelStyle),
          ),
        ),
      ),
      padding: EdgeInsets.all(0),
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(50),
      ),
      onPressed: onPressed,
    );
  };
}