showAlertDialog function

dynamic showAlertDialog(
  1. BuildContext context,
  2. dynamic nextRoute
)

Implementation

showAlertDialog(BuildContext context, nextRoute) {
  Widget continueButton = Row(
    mainAxisAlignment: MainAxisAlignment.center,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: [
      ElevatedButton(
        style: ElevatedButton.styleFrom(
            primary: Colors.white, onPrimary: Theme.of(context).primaryColor),
        child: const Text(
          "YES",
          style: TextStyle(
              color: Colors.black,
              fontFamily: "Aleo",
              fontSize: 22,
              letterSpacing: .4),
        ),
        onPressed: () {
          Navigator.of(context).pushNamed(nextRoute);
        },
      ),
      const SizedBox(
        width: 10,
      ),
      ElevatedButton(
        style: ElevatedButton.styleFrom(
            primary: Colors.white, onPrimary: Theme.of(context).primaryColor),
        child: const Text(
          "NO",
          style: TextStyle(
              color: Colors.black,
              fontFamily: "Aleo",
              fontSize: 22,
              letterSpacing: .4),
        ),
        onPressed: () {
          Navigator.pop(context);
        },
      ),
    ],
  );

  Dialog alert = Dialog(
    backgroundColor: Colors.transparent,
    insetPadding: const EdgeInsets.all(10),
    child: Container(
      width: MediaQuery.of(context).size.width / 2,
      height: 200,
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(15), color: Colors.amberAccent),
      padding: const EdgeInsets.fromLTRB(20, 50, 20, 20),
      child: Column(
        children: <Widget>[
          const Text("Chapter Skip",
              style: TextStyle(fontSize: 28, fontFamily: "Aleo"),
              textAlign: TextAlign.center),
          const Text("Are you sure about that?",
              style: TextStyle(fontSize: 24, fontFamily: "Aleo"),
              textAlign: TextAlign.center),
          const Spacer(),
          continueButton,
        ],
      ),
    ),
  );

  showDialog(
    context: context,
    builder: (BuildContext context) {
      return alert;
    },
  );
}