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 ? 2 : 0);
    return ElevatedButton(
      onPressed: onPressed,
      style: ElevatedButton.styleFrom(
        backgroundColor: Colors.transparent, // replaces `color`
        elevation: elevation,
        shadowColor: Colors.transparent, // if you want zero shadow
        splashFactory: NoSplash.splashFactory, // disables splash if needed
        padding: EdgeInsets.zero, // replaces `padding: EdgeInsets.all(0)`
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(50),
        ),
      ).copyWith(
        overlayColor: MaterialStateProperty.all(
            Colors.transparent), // replaces `splashColor`
      ),
      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),
            ).merge(labelStyle),
          ),
        ),
      ),
    );
  };
}