errorModal function

dynamic errorModal(
  1. BuildContext context,
  2. String title,
  3. String message,
  4. double height,
  5. Function? onButtonClick,
  6. String language,
)

Implementation

errorModal(BuildContext context, String title, String message, double height,
    Function? onButtonClick, String language) {
  double width = MediaQuery.of(context).size.width;

  showModalBottomSheet(
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(15.0),
    ),
    context: context,
    builder: (context) {
      return Container(
        padding: const EdgeInsets.all(30),
        height: height,
        width: width,
        child: Stack(
          children: [
            Align(
              alignment: Alignment.topCenter,
              child: Text(
                title,
                textAlign: TextAlign.center,
                style: const TextStyle(
                  color: textBlue,
                  fontSize: 20,
                  fontWeight: FontWeight.w600,
                ),
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: 50),
              child: Align(
                alignment: Alignment.center,
                child: Column(
                  children: [
                    Align(
                      alignment: Alignment.centerLeft,
                      child: Image.network(errorInfo),
                    ),
                    const SizedBox(
                      height: 5,
                    ),
                    Align(
                      alignment: Alignment.topRight,
                      child: Container(
                        width: width / 1.2,
                        padding: const EdgeInsets.all(15),
                        decoration: BoxDecoration(
                          color: greyBg,
                          borderRadius: BorderRadius.circular(10),
                        ),
                        child: Text(
                          message,
                          style: const TextStyle(
                            fontSize: 14,
                            fontWeight: FontWeight.w400,
                            color: buttonText,
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: 15),
              child: Align(
                alignment: Alignment.bottomCenter,
                child: Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(10),
                    gradient: const LinearGradient(colors: buttonGradient),
                  ),
                  width: width / 1.2,
                  padding: const EdgeInsets.all(7),
                  child: TextButton(
                    onPressed: () {
                      if (onButtonClick != null) {
                        onButtonClick();
                      }
                      Navigator.pop(context);
                    },
                    child: Text(
                      language == Languages.indonesian.value
                          ? "Coba lagi"
                          : 'Try again',
                      style: const TextStyle(
                          fontSize: 16,
                          fontWeight: FontWeight.w500,
                          color: Colors.white),
                    ),
                  ),
                ),
              ),
            )
          ],
        ),
      );
    },
  );
}