How to make an AlertDialog in Flutter?

前端 未结 9 2837
小蘑菇
小蘑菇 2020-11-29 00:56

I am learning to build apps in Flutter. Now I have come to alert dialogs. I have done them before in Android and iOS, but how do I make an alert in Flutter?

Here are

9条回答
  •  心在旅途
    2020-11-29 01:03

    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.

    Basic Alert:

    Alert(context: context, title: "RFLUTTER", desc: "Flutter is awesome.").show();
    

    Alert with Button:

    Alert(
        context: context,
        type: AlertType.error,
        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),
            width: 120,
        )
        ],
    ).show();
    

    You can also define generic alert styles.

    *I'm one of developer of RFlutter Alert.

提交回复
热议问题