How to style AlertDialog Actions in Flutter

后端 未结 6 884
抹茶落季
抹茶落季 2020-12-08 14:55

I use this method to show a AlertDialog:

_onSubmit(message) {
    if (message.isNotEmpty) {
      showDialog(
        context: context,
        barrierDismis         


        
6条回答
  •  臣服心动
    2020-12-08 15:30

    Or you can use RFlutter Alert library for that. It is easily customizable and easy-to-use. Its default style includes rounded corners and you can add buttons as much as you want.

    Alert Style:

    var alertStyle = AlertStyle(
        animationType: AnimationType.fromTop,
        isCloseButton: false,
        isOverlayTapDismiss: false,
        descStyle: TextStyle(fontWeight: FontWeight.bold),
        animationDuration: Duration(milliseconds: 400),
        alertBorder: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(0.0),
        side: BorderSide(
            color: Colors.grey,
        ),
        ),
        titleStyle: TextStyle(
        color: Colors.red,
        ),
    );
    

    And assing your AlertStyle object to Alert's style field.

    Alert(
        context: context,
        style: alertStyle,
        type: AlertType.info,
        title: "RFLUTTER ALERT",
        desc: "Flutter is more awesome with RFlutter Alert.",
        buttons: [
        DialogButton(
            child: Text(
            "COOL",
            style: TextStyle(color: Colors.white, fontSize: 20),
            ),
            onPressed: () => Navigator.pop(context),
            color: Color.fromRGBO(0, 179, 134, 1.0),
            radius: BorderRadius.circular(0.0),
        ),
        ],
    ).show();
    

    *I'm one of developer of RFlutter Alert.

提交回复
热议问题