showErrorDialog static method

dynamic showErrorDialog(
  1. BuildContext context,
  2. String title,
  3. String body, {
  4. String code = '200',
  5. String url = '#',
})

Implementation

static showErrorDialog(BuildContext context, String title, String body,
    {String code = '200', String url = '#'}) async {
  showDialog(
    context: context,
    builder: (BuildContext context) {
      Future<void> launchUrlFunction(String url) async {
        if (!await launchUrl(Uri.parse(url))) {
          throw Exception('Could not launch ${Uri.parse(url)}');
        }
      }

      return AlertDialog(
        title: Text(title),
        content: Text(body),
        actions: <Widget>[
          ElevatedButton(
            onPressed: () {
              launchUrlFunction(url);
            },
            style: ElevatedButton.styleFrom(
              backgroundColor: Colors.black,
              padding:
                  const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
            ),
            child: Text(
              title,
              style: const TextStyle(
                fontSize: 16.0,
                color: Colors.white,
              ),
            ),
          ),
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).pop();
            },
            style: ElevatedButton.styleFrom(
              backgroundColor: Colors.black,
              padding:
                  const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
            ),
            child: const Text(
              'Елемеу',
              style: TextStyle(
                fontSize: 16.0,
                color: Colors.white,
              ),
            ),
          ),
        ],
      );
    },
  );
}