goToSettings function

Future<void> goToSettings({
  1. required BuildContext context,
  2. required String title,
  3. required String content,
  4. required String buttonTitle,
})

Implementation

Future<void> goToSettings({
  required BuildContext context,
  required String title,
  required String content,
  required String buttonTitle,
}) async {
  await showDialog(
    context: context,
    builder: (context) {
      return AlertDialog(
        surfaceTintColor: Colors.white,
        title: Text(
          title,
          style: const TextStyle(
            fontSize: 18,
            color: Colors.black,
            fontWeight: FontWeight.bold,
          ),
        ),
        content: Text(
          content,
          style: const TextStyle(
            fontSize: 14,
            color: Colors.black,
          ),
        ),
        actions: [
          ElevatedButton(
            onPressed: () async {
              await openAppSettings();
              Navigator.of(context).pop();
            },
            style: ElevatedButton.styleFrom(
                surfaceTintColor: Colors.white,
                foregroundColor: Colors.black,
                side: const BorderSide(color: Colors.black)),
            child: Text(
              buttonTitle,
              style: const TextStyle(
                fontSize: 16,
                color: Colors.black,
              ),
            ),
          )
        ],
      );
    },
  );
}