Search code examples
flutterflutter-alertdialog

Change background color of DialogButton in Flutter


I am using rflutter_alert and I currently want to Change background color of DialogButton in my Flutter app and I am not getting it. Where should I modify my code with the color chosen for the button?

 // Showing Alert Dialog with Response JSON Message.
    Alert(
      context: context,
      type: AlertType.error,
      title: "",
      desc: "Usuario/Correo o contraseña incorrecta",
      buttons: [
        DialogButton(
          child: Text(
            "Cerrar",
            style: TextStyle(color: Colors.white, fontSize: 20),
          ),
          onPressed: () => Navigator.pop(context),
          width: 120,
        )
      ],
    ).show();
  }
} on TimeoutException catch (e) {
  setState(() {
    visible = false;
  });

Solution

  • Alert provides style parameter that can be used to customize the default behavior.

    Alert(
        style: AlertStyle(backgroundColor: Colors.amber),
    

    More about rflutter_alert