netwoke issue

This commit is contained in:
poojakhatawate 2024-07-08 10:28:57 +05:30
parent 7647e4737f
commit e1ecc9824c
7 changed files with 2147 additions and 507 deletions

33
lib/connectivity.dart Normal file
View File

@ -0,0 +1,33 @@
import 'dart:async';
import 'dart:io';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:dio/dio.dart';
class NetworkConnectivity {
// Future<bool> isInternetAvailable() async {
// var connectivityResult = await (Connectivity().checkConnectivity());
// return connectivityResult != ConnectivityResult.none;
// }
Future<bool> isInternetAvailable() async {
var connectivityResult = await Connectivity().checkConnectivity();
if (connectivityResult == ConnectivityResult.none) {
return false;
} else {
try {
// final result = await InternetAddress.lookup('google.com');
// return true;
final result = await Dio().get('www.google.com');
if (result.statusCode == 200) {
// if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
return true;
//}
}
return false;
} on SocketException catch (_) {
return false;
}
}
}
}

View File

@ -4,5 +4,6 @@ class Constants {
static Color k2color = Color.fromARGB(255, 0, 71, 132); static Color k2color = Color.fromARGB(255, 0, 71, 132);
//static const url = "http://192.168.172.50:8082/api"; //static const url = "http://192.168.172.50:8082/api";
static const url = 'http://192.168.2.143:8081/api'; static const url = 'http://192.168.2.143:8082/api';
//static const url = 'http://192.168.153.50:8081/api';
} }

View File

@ -304,13 +304,13 @@ class Contacts extends StatefulWidget {
class _ContactsState extends State<Contacts> { class _ContactsState extends State<Contacts> {
final _contactBox = Hive.box("mycontact"); final _contactBox = Hive.box("mycontact");
bool _switchValue = false; bool _switchValue = false;
bool isOnline2 = true; bool? isOnline2;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
setupConnectivityListener(); setupConnectivityListener();
getCall(); // getCall();
} }
Future<void> setupConnectivityListener() async { Future<void> setupConnectivityListener() async {
@ -323,6 +323,9 @@ class _ContactsState extends State<Contacts> {
isOnline2 = isOnline; isOnline2 = isOnline;
}); });
} }
if (isOnline2 == true) {
getCall();
}
} }
} }
@ -339,6 +342,7 @@ class _ContactsState extends State<Contacts> {
SystemChrome.setSystemUIOverlayStyle( SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132))); SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132)));
print("internet data_is: $isOnline2");
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
body: Consumer<hcpProvider>( body: Consumer<hcpProvider>(
@ -410,8 +414,8 @@ class _ContactsState extends State<Contacts> {
), ),
], ],
), ),
isOnline2 if (isOnline2 == true)
? Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: value.list.length, itemCount: value.list.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
@ -430,8 +434,7 @@ class _ContactsState extends State<Contacts> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => builder: (_) => NewProfile(text: data)));
NewProfile(text: data)));
}, },
leading: data["img_path"] == null leading: data["img_path"] == null
? ProfilePicture( ? ProfilePicture(
@ -464,7 +467,8 @@ class _ContactsState extends State<Contacts> {
}, },
), ),
) )
: Expanded( else
Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: _contactBox.values.length, itemCount: _contactBox.values.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {

View File

@ -3,6 +3,7 @@ import 'dart:io';
import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
class NetworkConnectivity { class NetworkConnectivity {
// Future<bool> isInternetAvailable() async { // Future<bool> isInternetAvailable() async {
@ -15,7 +16,10 @@ class NetworkConnectivity {
return false; return false;
} else { } else {
try { try {
// final result = await InternetAddress.lookup('google.com'); if (!kIsWeb) {
final result = await InternetAddress.lookup('google.com');
return true;
} else {
final result = await Dio().get('www.google.com'); final result = await Dio().get('www.google.com');
if (result.statusCode == 200) { if (result.statusCode == 200) {
@ -23,6 +27,14 @@ class NetworkConnectivity {
return true; return true;
//} //}
} }
}
// final result = await Dio().get('www.google.com');
// if (result.statusCode == 200) {
// // if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
// return true;
// //}
// }
return false; return false;
} on SocketException catch (_) { } on SocketException catch (_) {
return false; return false;

File diff suppressed because it is too large Load Diff

View File

@ -53,12 +53,12 @@ class _NewProfileState extends State<NewProfile> {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
print("pooja123"); print("pooja123");
//init();
getaffiliations(); getaffiliations();
getuserdetails(); getuserdetails();
init();
print("Widget_isssIndex_iss ${widget.text}"); print("Widget_isssIndex_iss ${widget.text}");
print( print(
"Widget_isssIndex_iss ${widget.text!["id"]},${widget.text!["name"]},${widget.text!["img_path"]}"); "Widget_isssIndex_iss ${widget.text!["id"]},${widget.text!["name"]},${widget.text!["img_path"]}");
@ -72,7 +72,7 @@ class _NewProfileState extends State<NewProfile> {
// if(data.g) // if(data.g)
data.getRecords("form-3 demo"); data.getRecords("form-3 demo");
setState(() {}); // setState(() {});
} }
getaffiliations() async { getaffiliations() async {

View File

@ -1,145 +1,101 @@
// import 'package:discover_module/ui_screen/interactionform/configprovider.dart'; import 'package:discover_module/ui_screen/interactionform/configprovider.dart';
// import 'package:discover_module/ui_screen/interactionform/interaction_screen.dart'; import 'package:discover_module/ui_screen/interactionform/interaction_screen.dart';
// import 'package:discover_module/ui_screen/interactionform/interactionlistscreen.dart'; import 'package:discover_module/ui_screen/interactionform/interactionlistscreen.dart';
// import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart'; import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart';
// import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart'; import 'package:discover_module/ui_screen/interactionform/model/save_interaction.dart';
// import 'package:discover_module/ui_screen/interactionform/view_forms_list.dart'; import 'package:discover_module/ui_screen/interactionform/view_forms_list.dart';
// import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
// import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
// class FormList extends StatefulWidget { class FormList extends StatefulWidget {
// const FormList({super.key}); const FormList({super.key});
// @override @override
// State<FormList> createState() => _FormListState(); State<FormList> createState() => _FormListState();
}
class _FormListState extends State<FormList> {
List<SaveInteraction> savedList = [];
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// if (!mytimer!.isActive) {
// activateTimer();
// } // }
print("interactionListt");
init();
});
// class _FormListState extends State<FormList> { super.initState();
// List<SaveInteraction> savedList = []; }
// @override
// void initState() {
// WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
// // if (!mytimer!.isActive) {
// // activateTimer();
// // }
// print("interactionListt");
// init();
// });
// super.initState(); init() async {
// } print("init");
// init() async { await Provider.of<InteractionProvider>(context, listen: false)
// print("init"); .initConfigData();
print("init1");
// await Provider.of<InteractionProvider>(context, listen: false) await Provider.of<InteractionProvider>(context, listen: false).getRecords();
// .initConfigData(); print("init2");
// await Provider.of<InteractionProvider>(context, listen: false).getRecords();
//setState(() {}); //setState(() {});
// } }
// Future<int> getCount(String form, InteractionProvider provider) async { Future<int> getCount(String form, InteractionProvider provider) async {
// await provider.getRecords(); await provider.getRecords();
// return provider.savedList.where((element) => element.form == form).length; return provider.savedList.where((element) => element.form == form).length;
// } }
// @override @override
// Widget build(BuildContext context) { Widget build(BuildContext context) {
// return Consumer<InteractionProvider>( return Consumer<InteractionProvider>(
// builder: (BuildContext context, provider, Widget? child) { builder: (BuildContext context, provider, Widget? child) {
// return SafeArea( return SafeArea(
// child: Scaffold( child: Scaffold(
// appBar: AppBar( appBar: AppBar(
// title: Text("Form List"), title: Text("Form List"),
// ), ),
// body: ListView.builder( body: provider.intConfigDataList.length == 1
// itemCount: provider.intConfigDataList.length, ? ListView.builder(
// cacheExtent: itemCount: provider.intConfigDataList.length,
// double.parse(provider.intConfigDataList.length.toString()), cacheExtent: double.parse(
// itemBuilder: (context, index) { provider.intConfigDataList.length.toString()),
// return Column( itemBuilder: (context, index) {
// children: [ print("checkkkk");
// ListTile( return Column(
// title: const Text( children: [
// "Add My Event", ListTile(
// style: TextStyle(fontSize: 18.0), title: const Text(
// ), "Add My Event",
// onTap: () async { style: TextStyle(fontSize: 18.0),
// final ConfigDataProvider configDataProvider = ),
// ConfigDataProvider(); onTap: () async {
final ConfigDataProvider configDataProvider =
// await configDataProvider.initConfigUIData123(); ConfigDataProvider();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// const InteractionListScreen()));
// // Navigator.push(context,
// // MaterialPageRoute(builder: (context) => AddEventScreen()));
// },
// trailing: const Icon(Icons.arrow_forward_ios),
// ),
// Divider(),
// // ListTile(
// // title: const Text(
// // "Interaction",
// // style: TextStyle(fontSize: 18.0),
// // ),
// // onTap: () async {
// // print("I am Interaction");
// // final ConfigDataProvider configDataProvider =
// // ConfigDataProvider();
// // await configDataProvider.initConfigUIData();
// // // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
// // Navigator.push(
// // context,
// // MaterialPageRoute(
// // builder: (context) => InteractionListScreen()));
// // },
// // trailing: const Icon(Icons.arrow_forward_ios),
// // ),
await configDataProvider.initConfigUIData123();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InteractionListScreen()));
// Navigator.push(context,
// MaterialPageRoute(builder: (context) => AddEventScreen()));
},
trailing: const Icon(Icons.arrow_forward_ios),
),
Divider(),
// ListTile( // ListTile(
// title: const Text( // title: const Text(
// "Interaction", // "Interaction",
// style: TextStyle(fontSize: 18.0), // style: TextStyle(fontSize: 18.0),
// ), // ),
// onTap: () async { // onTap: () async {
// print( // print("I am Interaction");
// "I am Interaction:${index}, ${provider.intConfigDataList[index].name}");
// // final ConfigDataProvider configDataProvider =
// // ConfigDataProvider();
// // await configDataProvider.initConfigUIData();
// // // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
// // Navigator.push(
// // context,
// // MaterialPageRoute(
// // builder: (context) => InteractionListScreen()));
// if (provider.intConfigDataList.length == 1) {
// setState(() {});
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIData();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (BuildContext context) =>
// InteractionScreen(
// index: index,
// form: provider
// .intConfigDataList[index].name,
// )));
// } else {
// final ConfigDataProvider configDataProvider = // final ConfigDataProvider configDataProvider =
// ConfigDataProvider(); // ConfigDataProvider();
@ -148,50 +104,99 @@
// Navigator.push( // Navigator.push(
// context, // context,
// MaterialPageRoute( // MaterialPageRoute(
// builder: (context) => // builder: (context) => InteractionListScreen()));
// InteractionListScreen()));
// }
// }, // },
// trailing: const Icon(Icons.arrow_forward_ios), // trailing: const Icon(Icons.arrow_forward_ios),
// ), // ),
// const Divider(),
// ListTile( ListTile(
// title: const Text( title: const Text(
// "New Medical Insight", "Interaction",
// style: TextStyle(fontSize: 18.0), style: TextStyle(fontSize: 18.0),
// ), ),
// onTap: () async { onTap: () async {
print(
"I am Interaction:${index}, ${provider.intConfigDataList[index].name}");
// final ConfigDataProvider configDataProvider = // final ConfigDataProvider configDataProvider =
// ConfigDataProvider(); // ConfigDataProvider();
// await configDataProvider.initConfigUIDataMedical(); // await configDataProvider.initConfigUIData();
// // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
// Navigator.push( // Navigator.push(
// context, // context,
// MaterialPageRoute( // MaterialPageRoute(
// builder: (context) => // builder: (context) => InteractionListScreen()));
// const InteractionListScreen()));
// }, if (provider.intConfigDataList.length == 1) {
// trailing: Icon(Icons.arrow_forward_ios), setState(() {});
// ),
// Divider(), final ConfigDataProvider configDataProvider =
// ListTile( ConfigDataProvider();
// title: const Text(
// "Engagement", await configDataProvider.initConfigUIData();
// style: TextStyle(fontSize: 18.0), Navigator.push(
// ), context,
// onTap: () async { MaterialPageRoute(
// final ConfigDataProvider configDataProvider = builder: (BuildContext context) =>
// ConfigDataProvider(); InteractionScreen(
// await configDataProvider.initConfigUIDataEng(); index: index,
// Navigator.push( form: provider
// context, .intConfigDataList[index].name,
// MaterialPageRoute( )));
// builder: (context) => } else {
// const InteractionListScreen())); final ConfigDataProvider configDataProvider =
// }, ConfigDataProvider();
// trailing: const Icon(Icons.arrow_forward_ios),
// ), await configDataProvider.initConfigUIData();
// Divider(), // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
InteractionListScreen()));
}
},
trailing: const Icon(Icons.arrow_forward_ios),
),
const Divider(),
ListTile(
title: const Text(
"New Medical Insight",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIDataMedical();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InteractionListScreen()));
},
trailing: Icon(Icons.arrow_forward_ios),
),
Divider(),
ListTile(
title: const Text(
"Engagement",
style: TextStyle(fontSize: 18.0),
),
onTap: () async {
final ConfigDataProvider configDataProvider =
ConfigDataProvider();
await configDataProvider.initConfigUIDataEng();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const InteractionListScreen()));
},
trailing: const Icon(Icons.arrow_forward_ios),
),
Divider(),
// ListTile( // ListTile(
// title: Row( // title: Row(
// children: [ // children: [
@ -274,57 +279,12 @@
// ))); // )));
// }, // },
// ), // ),
// const Divider(),
// ],
// );
// }),
// ),
// );
// });
// }
// }
import 'package:discover_module/ui_screen/interactionform/configprovider.dart'; const Divider(),
import 'package:discover_module/ui_screen/interactionform/interactionlistscreen.dart'; ],
import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart'; );
import 'package:flutter/cupertino.dart'; })
import 'package:flutter/material.dart'; : ListView(
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
class FormList extends StatefulWidget {
const FormList({super.key});
@override
State<FormList> createState() => _FormListState();
}
class _FormListState extends State<FormList> {
var formdata;
@override
void initState() {
// TODO: implement initState
super.initState();
idata();
}
idata() {
var iprovider = Provider.of<InteractionProvider>(context, listen: false);
setState(() {
formdata = iprovider.intConfigDataList;
});
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
title: Text("Form List"),
),
body: ListView(
children: [ children: [
ListTile( ListTile(
title: const Text( title: const Text(
@ -339,7 +299,8 @@ class _FormListState extends State<FormList> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const InteractionListScreen())); builder: (context) =>
const InteractionListScreen()));
// Navigator.push(context, // Navigator.push(context,
// MaterialPageRoute(builder: (context) => AddEventScreen())); // MaterialPageRoute(builder: (context) => AddEventScreen()));
}, },
@ -400,7 +361,8 @@ class _FormListState extends State<FormList> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const InteractionListScreen())); builder: (context) =>
const InteractionListScreen()));
}, },
trailing: Icon(Icons.arrow_forward_ios), trailing: Icon(Icons.arrow_forward_ios),
), ),
@ -417,7 +379,8 @@ class _FormListState extends State<FormList> {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const InteractionListScreen())); builder: (context) =>
const InteractionListScreen()));
}, },
trailing: const Icon(Icons.arrow_forward_ios), trailing: const Icon(Icons.arrow_forward_ios),
), ),
@ -426,5 +389,151 @@ class _FormListState extends State<FormList> {
), ),
), ),
); );
});
} }
} }
// import 'package:discover_module/ui_screen/interactionform/configprovider.dart';
// import 'package:discover_module/ui_screen/interactionform/interactionlistscreen.dart';
// import 'package:discover_module/ui_screen/interactionform/interactionprovider.dart';
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter/widgets.dart';
// import 'package:provider/provider.dart';
// class FormList extends StatefulWidget {
// const FormList({super.key});
// @override
// State<FormList> createState() => _FormListState();
// }
// class _FormListState extends State<FormList> {
// var formdata;
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// idata();
// }
// idata() {
// var iprovider = Provider.of<InteractionProvider>(context, listen: false);
// setState(() {
// formdata = iprovider.intConfigDataList;
// });
// }
// @override
// Widget build(BuildContext context) {
// return SafeArea(
// child: Scaffold(
// appBar: AppBar(
// title: Text("Form List"),
// ),
// body: ListView(
// children: [
// ListTile(
// title: const Text(
// "Add My Event",
// style: TextStyle(fontSize: 18.0),
// ),
// onTap: () async {
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIData123();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const InteractionListScreen()));
// // Navigator.push(context,
// // MaterialPageRoute(builder: (context) => AddEventScreen()));
// },
// trailing: const Icon(Icons.arrow_forward_ios),
// ),
// Divider(),
// // ListTile(
// // title: const Text(
// // "Interaction",
// // style: TextStyle(fontSize: 18.0),
// // ),
// // onTap: () async {
// // print("I am Interaction");
// // final ConfigDataProvider configDataProvider =
// // ConfigDataProvider();
// // await configDataProvider.initConfigUIData();
// // // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
// // Navigator.push(
// // context,
// // MaterialPageRoute(
// // builder: (context) => InteractionListScreen()));
// // },
// // trailing: const Icon(Icons.arrow_forward_ios),
// // ),
// ListTile(
// title: const Text(
// "Interaction",
// style: TextStyle(fontSize: 18.0),
// ),
// onTap: () async {
// print("I am Interaction");
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIData();
// // Navigator.push(context, MaterialPageRoute(builder: (context)))=> InteractionScreen();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => InteractionListScreen()));
// },
// trailing: const Icon(Icons.arrow_forward_ios),
// ),
// const Divider(),
// ListTile(
// title: const Text(
// "New Medical Insight",
// style: TextStyle(fontSize: 18.0),
// ),
// onTap: () async {
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIDataMedical();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const InteractionListScreen()));
// },
// trailing: Icon(Icons.arrow_forward_ios),
// ),
// Divider(),
// ListTile(
// title: const Text(
// "Engagement",
// style: TextStyle(fontSize: 18.0),
// ),
// onTap: () async {
// final ConfigDataProvider configDataProvider =
// ConfigDataProvider();
// await configDataProvider.initConfigUIDataEng();
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const InteractionListScreen()));
// },
// trailing: const Icon(Icons.arrow_forward_ios),
// ),
// Divider(),
// ],
// ),
// ),
// );
// }
// }