no internet, error screen
This commit is contained in:
BIN
assets/images/no_internet/png/no_internet.png
Normal file
BIN
assets/images/no_internet/png/no_internet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -15,7 +15,7 @@ class RouteName {
|
||||
static const String registerUserDetailsScreen = 'registerUserDetailsScreen';
|
||||
|
||||
//No Internet
|
||||
static const String noInternetScreen = 'noInternet';
|
||||
static const String noInternetScreen = 'noInternetScreen';
|
||||
|
||||
//Welcome
|
||||
static const String welcomeScreen = 'welcome';
|
||||
|
||||
@@ -25,6 +25,7 @@ import 'package:tanami_app/features/register/presentation/pages/register_screen.
|
||||
import 'package:tanami_app/features/register/presentation/pages/register_step_screen.dart';
|
||||
import 'package:tanami_app/features/securePin/presentation/pages/pin_screen.dart';
|
||||
import 'package:tanami_app/features/welcome/presentation/pages/weclome_screen.dart';
|
||||
import 'package:tanami_app/shared/components/no_internet.dart';
|
||||
|
||||
import '../../features/MainScreens/main_screen.dart';
|
||||
import '../../features/forgotPassword/presentation/pages/restore_password_phone_verification_screen.dart';
|
||||
@@ -254,6 +255,13 @@ final goRouter = GoRouter(
|
||||
return const ConfirmInvestmentScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
name: RouteName.noInternetScreen,
|
||||
path: RouteName.noInternetScreen,
|
||||
builder: (context, state) {
|
||||
return const NoInternet();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -116,4 +116,9 @@ class AppImages {
|
||||
'assets/images/invest_screen/svg/time_square.svg';
|
||||
static const String applePayIcon =
|
||||
'assets/images/invest_screen/svg/apple_pay.svg';
|
||||
|
||||
//No Internet
|
||||
|
||||
static const String noInternetImage =
|
||||
'assets/images/no_internet/png/no_internet.png';
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// network_connectivity.dart
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:tanami_app/core/routes/route_name.dart';
|
||||
import 'package:tanami_app/core/routes/routes.dart';
|
||||
@@ -30,7 +31,7 @@ class NetworkConnectivity {
|
||||
goRouter.pop(true);
|
||||
}
|
||||
} else {
|
||||
goRouter.go(RouteName.noInternetScreen);
|
||||
goRouter.pushNamed(RouteName.noInternetScreen);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -45,7 +46,7 @@ class NetworkConnectivity {
|
||||
onStatusChange(connectivityResult.toString());
|
||||
} else {
|
||||
onStatusChange(connectivityResult.toString());
|
||||
goRouter.go(RouteName.noInternetScreen);
|
||||
goRouter.pushNamed(RouteName.noInternetScreen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'core/routes/routes.dart';
|
||||
import 'core/utils/connectivity/network_connectivity.dart';
|
||||
import 'features/countrySelection/presentation/bloc/choose_country_bloc.dart';
|
||||
import 'shared/components/bloc/bottom_nav_bar/bottom_navigation_bloc.dart';
|
||||
import 'shared/components/error_widget.dart';
|
||||
|
||||
/* CREATED BY - JAYESH JAIN
|
||||
DATE - 24-05-2024
|
||||
@@ -16,6 +17,12 @@ import 'shared/components/bloc/bottom_nav_bar/bottom_navigation_bloc.dart';
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
FlutterError.dumpErrorToConsole(details);
|
||||
runApp(CustomErrorWidget(
|
||||
errorMessage: details.toString(),
|
||||
));
|
||||
};
|
||||
// Set the preferred orientations of the device.
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
@@ -63,8 +70,8 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
builder: (BuildContext context, Widget? child) => MaterialApp.router(
|
||||
title: 'Tanami Capital',
|
||||
theme: ThemeData(
|
||||
// useMaterial3: true,
|
||||
),
|
||||
useMaterial3: true,
|
||||
),
|
||||
debugShowCheckedModeBanner: false,
|
||||
routerConfig: goRouter,
|
||||
),
|
||||
|
||||
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),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
])),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -120,3 +120,5 @@ flutter:
|
||||
- assets/images/language_screen/png/
|
||||
- assets/images/invest_screen/
|
||||
- assets/images/invest_screen/svg/
|
||||
- assets/images/no_internet/
|
||||
- assets/images/no_internet/png/
|
||||
|
||||
Reference in New Issue
Block a user