offline notification
This commit is contained in:
parent
069db374fa
commit
8363463eb0
BIN
assets/logos/no-internet.png
Normal file
BIN
assets/logos/no-internet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
@ -299,6 +299,7 @@ import 'package:uae_stat/presentation/Screens/auth_verification/registration.dar
|
||||
import 'package:uae_stat/presentation/Screens/charts/chart.dart';
|
||||
import 'package:uae_stat/presentation/Screens/charts/screens/chart_screen.dart';
|
||||
import 'package:uae_stat/presentation/Screens/demo_home2.dart';
|
||||
import 'package:uae_stat/presentation/Screens/online_offline_verification/internet_check.dart';
|
||||
import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/getting_started.dart';
|
||||
import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart';
|
||||
|
||||
@ -329,6 +330,11 @@ final GoRouter router = GoRouter(
|
||||
//builder: (context, state) => LoginRoute(),
|
||||
builder: (context, state) => MyHomePage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/internetcheck',
|
||||
builder: (context, state) => InternetCheck(),
|
||||
|
||||
),
|
||||
GoRoute(
|
||||
path: '/login',
|
||||
builder: (context, state) => LoginRoute(),
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
|
||||
class ConnectivityService {
|
||||
final Connectivity _connectivity = Connectivity();
|
||||
|
||||
// This will hold the connectivity status
|
||||
Stream<List<ConnectivityResult>> get connectivityStream =>
|
||||
_connectivity.onConnectivityChanged;
|
||||
}
|
||||
|
||||
// The provider that will provide the connectivity service
|
||||
final connectivityServiceProvider = Provider<ConnectivityService>((ref) {
|
||||
return ConnectivityService();
|
||||
});
|
||||
|
||||
// StateNotifier to manage connectivity state
|
||||
class ConnectivityNotifier extends StateNotifier<bool> {
|
||||
final ConnectivityService _connectivityService;
|
||||
|
||||
ConnectivityNotifier(this._connectivityService) : super(true) {
|
||||
_connectivityService.connectivityStream.listen((result) {
|
||||
state = result != ConnectivityResult.none;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// The provider for the connectivity state
|
||||
final connectivityProvider = StateNotifierProvider<ConnectivityNotifier, bool>((ref) {
|
||||
final connectivityService = ref.read(connectivityServiceProvider);
|
||||
return ConnectivityNotifier(connectivityService);
|
||||
});
|
||||
@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:uae_stat/presentation/components/constant/constant.dart';
|
||||
|
||||
class InternetCheck extends StatelessWidget {
|
||||
const InternetCheck({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double myheight = MediaQuery.of(context).size.height;
|
||||
double mywidth = MediaQuery.of(context).size.width;
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Image(image: AssetImage('assets/logos/no-internet.png')),
|
||||
SizedBox(height: myheight/40,),
|
||||
Text("No Internet Connection",style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold)),
|
||||
Text("Please check with your Wi-Fi or Mobile",style: TextStyle(fontSize: 15,fontWeight: FontWeight.w500)),
|
||||
Text("Data connection and try again",style: TextStyle(fontSize: 15,fontWeight: FontWeight.w500)),
|
||||
SizedBox(height: myheight/40,),
|
||||
ElevatedButton(
|
||||
onPressed: (){
|
||||
Navigator.pop(context);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Color(
|
||||
0xFFA7887A), // Brownish color for Register
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Retry",
|
||||
style: TextStyle(
|
||||
fontSize: 16, color: Colors.white),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Icon(Icons.arrow_forward_ios_outlined,size: 12,
|
||||
color: Colors.white),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -162,13 +162,40 @@
|
||||
// }
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:uae_stat/infrastructure/services/InternetConnectivity_Service/InternetConnectivityService.dart';
|
||||
import 'package:uae_stat/presentation/Screens/online_offline_verification/internet_check.dart';
|
||||
import '../../drawer_routes/custom_drawer_routes.dart';
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
class MyHomePage extends ConsumerWidget {
|
||||
const MyHomePage({super.key});
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final isConnected = ref.watch(connectivityProvider);
|
||||
//final isConnected = false;
|
||||
double myheight = MediaQuery.of(context).size.height;
|
||||
double mywidth = MediaQuery.of(context).size.width;
|
||||
|
||||
print('Connectivity Status: $isConnected');
|
||||
|
||||
// Trigger navigation based on connectivity state
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (isConnected == false) {
|
||||
context.go('/internetcheck');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return BaseScaffold(
|
||||
mycenterTitle: true,
|
||||
title: SizedBox(
|
||||
height: myheight / 5,
|
||||
width: mywidth / 3,
|
||||
child: Image(image: AssetImage('assets/logos/uae_stat.png'))),
|
||||
body: EconomyStats(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void handleInfoCardClick(BuildContext context, String data) {
|
||||
@ -185,22 +212,6 @@ void handleInfoCardClick(BuildContext context, String data) {
|
||||
}
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double myheight = MediaQuery.of(context).size.height;
|
||||
double mywidth = MediaQuery.of(context).size.width;
|
||||
return BaseScaffold(
|
||||
mycenterTitle: true,
|
||||
title: SizedBox(
|
||||
height: myheight / 5,
|
||||
width: mywidth / 3,
|
||||
child: Image(image: AssetImage('assets/logos/uae_stat.png'))),
|
||||
body: EconomyStats(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EconomyStats extends StatelessWidget {
|
||||
const EconomyStats({Key? key}) : super(key: key);
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import connectivity_plus
|
||||
import file_selector_macos
|
||||
import flutter_secure_storage_macos
|
||||
import path_provider_foundation
|
||||
@ -15,6 +16,7 @@ import video_player_avfoundation
|
||||
import webview_flutter_wkwebview
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
|
||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
|
||||
80
pubspec.lock
80
pubspec.lock
@ -5,23 +5,23 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
sha256: f256b0c0ba6c7577c15e2e4e114755640a875e885099367bf6e012b19314c834
|
||||
sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "72.0.0"
|
||||
version: "76.0.0"
|
||||
_macros:
|
||||
dependency: transitive
|
||||
description: dart
|
||||
source: sdk
|
||||
version: "0.3.2"
|
||||
version: "0.3.3"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
sha256: b652861553cd3990d8ed361f7979dc6d7053a9ac8843fa73820ab68ce5410139
|
||||
sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.7.0"
|
||||
version: "6.11.0"
|
||||
analyzer_plugin:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -186,10 +186,26 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
||||
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.18.0"
|
||||
version: "1.19.0"
|
||||
connectivity_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: connectivity_plus
|
||||
sha256: "8a68739d3ee113e51ad35583fdf9ab82c55d09d693d3c39da1aebab87c938412"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.2"
|
||||
connectivity_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: connectivity_plus_platform_interface
|
||||
sha256: "42657c1715d48b167930d5f34d00222ac100475f73d10162ddf43e714932f204"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -266,10 +282,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: custom_lint_visitor
|
||||
sha256: "8aeb3b6ae2bb765e7716b93d1d10e8356d04e0ff6d7592de6ee04e0dd7d6587d"
|
||||
sha256: bfe9b7a09c4775a587b58d10ebb871d4fe618237639b1e84d5ec62d7dfef25f9
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0+6.7.0"
|
||||
version: "1.0.0+6.11.0"
|
||||
dart_style:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -278,6 +294,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.7"
|
||||
dbus:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dbus
|
||||
sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.10"
|
||||
equatable:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -781,18 +805,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker
|
||||
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
|
||||
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.0.5"
|
||||
version: "10.0.7"
|
||||
leak_tracker_flutter_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_flutter_testing
|
||||
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
|
||||
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.5"
|
||||
version: "3.0.8"
|
||||
leak_tracker_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -821,10 +845,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: macros
|
||||
sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536"
|
||||
sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.2-main.4"
|
||||
version: "0.1.3-main.0"
|
||||
mailer:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -889,6 +913,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
nm:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: nm
|
||||
sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.0"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1180,7 +1212,7 @@ packages:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
version: "0.0.0"
|
||||
smart_api_client:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1224,10 +1256,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
||||
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
version: "1.12.0"
|
||||
state_notifier:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1256,10 +1288,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
||||
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.3.0"
|
||||
syncfusion_flutter_charts:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1288,10 +1320,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
|
||||
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.2"
|
||||
version: "0.7.3"
|
||||
the_validator:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1448,10 +1480,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
|
||||
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.2.5"
|
||||
version: "14.3.0"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -60,6 +60,7 @@ dependencies:
|
||||
syncfusion_flutter_charts: 28.1.33
|
||||
material_charts: ^0.0.23
|
||||
flutter_staggered_grid_view: ^0.7.0
|
||||
connectivity_plus: ^6.1.2
|
||||
|
||||
dependency_overrides:
|
||||
fading_edge_scrollview: ^4.1.1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user