import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:onufitness/constants/color_constant.dart'; import 'package:onufitness/constants/text_constant.dart'; class NoInternetDialog extends StatelessWidget { const NoInternetDialog({super.key}); Future retryConnection() async { final result = await Connectivity().checkConnectivity(); if (result == ConnectivityResult.mobile || result == ConnectivityResult.wifi) { Get.back(); } } @override Widget build(BuildContext context) { return AlertDialog( backgroundColor: textFieldFillColor, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), titlePadding: const EdgeInsets.only(top: 24, left: 24, right: 24), contentPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), actionsPadding: const EdgeInsets.only(bottom: 12, right: 12), title: Row( children: [ Icon(Icons.wifi_off, color: Color(primaryColor), size: 28), const SizedBox(width: 10), Text( "No Internet Connection", style: TextStyle( fontWeight: FontWeight.bold, fontSize: regularSizeText, color: Colors.black87, ), ), ], ), content: Text( "You are offline. Please check your internet connection and try again.", style: TextStyle(fontSize: smallSizeText, color: Colors.black54), ), actions: [ TextButton( onPressed: () { retryConnection(); }, style: TextButton.styleFrom( backgroundColor: Color(primaryColor), padding: EdgeInsets.symmetric(horizontal: 20.sp, vertical: 6.sp), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), ), child: const Text( "Retry", style: TextStyle(color: Colors.black, fontWeight: FontWeight.w600), ), ), ], ); } }