no internet, error screen
This commit is contained in:
34
lib/shared/components/error_widget.dart
Normal file
34
lib/shared/components/error_widget.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomErrorWidget extends StatelessWidget {
|
||||
final String errorMessage;
|
||||
|
||||
const CustomErrorWidget({super.key, required this.errorMessage});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
color: Colors.red,
|
||||
size: 50.0,
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
const Text(
|
||||
'Error Occurred!',
|
||||
style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
Text(
|
||||
errorMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 16.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
86
lib/shared/components/no_internet.dart
Normal file
86
lib/shared/components/no_internet.dart
Normal file
@@ -0,0 +1,86 @@
|
||||
// ignore_for_file: file_names, sized_box_for_whitespace
|
||||
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:tanami_app/core/routes/routes.dart';
|
||||
import 'package:tanami_app/core/styles/app_color.dart';
|
||||
import 'package:tanami_app/shared/components/toast_message.dart';
|
||||
|
||||
import '../../core/styles/app_images.dart';
|
||||
|
||||
class NoInternet extends StatelessWidget {
|
||||
const NoInternet({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () => Future.value(false),
|
||||
child: Scaffold(
|
||||
body: Column(children: [
|
||||
Center(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 100),
|
||||
height: 180.h,
|
||||
width: 1.sw,
|
||||
child: Image.asset(AppImages.noInternetImage),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 100),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 15.0,
|
||||
),
|
||||
Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Text(
|
||||
"Internet Connection is Down!\n\nEnsure your internet's up and running.",
|
||||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.dmSans(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
)),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30.0,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final connectivityResult =
|
||||
await (Connectivity().checkConnectivity());
|
||||
if (connectivityResult[0] == ConnectivityResult.wifi ||
|
||||
connectivityResult[0] == ConnectivityResult.mobile) {
|
||||
goRouter.pop();
|
||||
} else {
|
||||
errorToastMessage(context, "Internet is still down");
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: 54.h,
|
||||
width: 330.w,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10.h),
|
||||
color: AppColor.primaryColor2),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"Try Again",
|
||||
style: GoogleFonts.dmSans(
|
||||
color: AppColor.plainWhite, fontSize: 20.sp),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
])),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user