KonectarEvents/lib/contacts_module/ui_screen/saved_profiles/saved_contact.dart

1309 lines
57 KiB
Dart
Raw Normal View History

2024-10-08 12:01:59 +00:00
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:konectar_events/contacts_module/constants.dart';
import 'package:konectar_events/contacts_module/custom_widget/text.dart';
import 'package:konectar_events/contacts_module/hive_fun.dart';
import 'package:konectar_events/contacts_module/provider_class/hcp%20_provider.dart';
import 'package:konectar_events/contacts_module/storage_hive/aff_data/insert_aff.dart';
import 'package:konectar_events/contacts_module/storage_hive/events_data/crud_event.dart';
import 'package:konectar_events/contacts_module/storage_hive/kol_info/curd_kol.dart';
import 'package:konectar_events/contacts_module/storage_hive/pub_data/curd_pub.dart';
import 'package:konectar_events/contacts_module/storage_hive/trials_data/crud_trials.dart';
import 'package:konectar_events/contacts_module/ui_screen/interactionform/util.dart';
import 'package:konectar_events/contacts_module/ui_screen/saved_profiles/saved_profile_info.dart';
// import 'package:konectar_events/constants.dart';
// import 'package:konectar_events/custom_widget/text.dart';
// import 'package:konectar_events/hive_fun.dart';
// import 'package:konectar_events/provider_class/affiliationsprovider.dart';
// import 'package:konectar_events/provider_class/events_provider.dart';
// import 'package:konectar_events/provider_class/hcp%20_provider.dart';
// import 'package:konectar_events/provider_class/publications_provider.dart';
// import 'package:konectar_events/provider_class/trials_provider.dart';
// import 'package:konectar_events/storage_hive/aff_data/insert_aff.dart';
// import 'package:konectar_events/storage_hive/events_data/crud_event.dart';
// import 'package:konectar_events/storage_hive/kol_info/curd_kol.dart';
// import 'package:konectar_events/storage_hive/kol_info/kol_info_model_hive.dart';
// import 'package:konectar_events/storage_hive/pub_data/curd_pub.dart';
// import 'package:konectar_events/storage_hive/trials_data/crud_trials.dart';
// import 'package:konectar_events/ui_screen/filters_menu.dart';
// import 'package:konectar_events/ui_screen/interactionform/util.dart';
// import 'package:konectar_events/ui_screen/new_new_profile.dart';
// import 'package:konectar_events/ui_screen/new_new_profile_offline.dart';
// import 'package:konectar_events/ui_screen/saved_profiles/saved_profile_info.dart';
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:dropdownfield2/dropdownfield2.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
import 'package:flutter_profile_picture/flutter_profile_picture.dart';
import 'package:hive_flutter/hive_flutter.dart';
// import 'package:konectar_events/ui_screen/interactionform/NewtworkConnectivity.dart';
class SavedContacts1 extends StatefulWidget {
const SavedContacts1({Key? key}) : super(key: key);
@override
State<SavedContacts1> createState() => SavedContacts1State();
}
class SavedContacts1State extends State<SavedContacts1> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
// final contactBox = Hive.box("mycontact");
bool _switchValue = false;
bool isOnline2 = true;
final TextEditingController _searchController = TextEditingController();
List<String> ddlist = ["aaaa", 'bbb'];
// List<String> ddlist = ['Option 1', 'Option 2', 'Option 3'];
String _selectedValue = '';
String? _selectedValue1;
String dropdownvalue = 'Profile Type';
// List of items in our dropdown menu
var items = [
'Profile Type',
'HCP Name',
'Speciality',
'Country',
'Region',
'State',
'City',
'List',
'Organization',
'Event',
];
bool isSearchClickd = false;
final List<String> _items = ['Option 1', 'Option 2', 'Option 3'];
TextEditingController textEditingController = TextEditingController();
List displayedHCPList = [];
bool ActiveConnection = false;
String T = "";
bool isChecked = false;
//final Set<int> _selectedIndices = Set();
final List<String> _selectedIndices = [];
final List<int> _selectedremoveIndices = [];
bool longpress = false;
bool longpressmy = false;
List offlinekoldata = [];
@override
void initState() {
super.initState();
data();
}
data() async {
offlinekoldata = await retrievekol();
setState(() {});
print("Lenghtttthhhh: ${offlinekoldata.length}");
}
@override
Widget build(BuildContext context) {
// print("ProfileType $dropdownvalue, $_selectedValue1");
// print("all StoredUser: ${HiveFunctions.getAllUsers11()}");
if (_selectedValue1 == "Profile Type") {
print("PPPP11");
setState(() {
ddlist = [
"All Profile",
'Full Profile',
'Basic Profile',
];
});
} else if (_selectedValue1 == "HCP Name") {
print("kkkofflinekoldata ${offlinekoldata.map((e) => e.name)}");
List<String> data = offlinekoldata.map((e) => e.name.toString()).toList();
print("Kol_name_data: $data");
setState(() {
ddlist = data;
});
} else if (_selectedValue1 == "Speciality") {
print("kkk");
List<String> dataspl =
offlinekoldata.map((e) => e.speciality.toString()).toList();
setState(() {
ddlist = dataspl;
});
// setState(() {
// ddlist = [
// "Cardiovascular Disease",
// 'Interventional Cardiology',
// "Cardiovascular Disease",
// ];
// });
} else if (_selectedValue1 == "Country") {
print("kkk");
setState(() {
ddlist = [
"United States",
"United States",
"United States",
];
});
} else if (_selectedValue1 == "State") {
print("kkk");
setState(() {
ddlist = [
"Karnataka",
'Karnataka',
'Karnataka',
];
});
} else if (_selectedValue1 == "City") {
print("kkk");
setState(() {
ddlist = [
"Hubli",
'Hubli',
'Hubli',
];
});
}
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Color.fromARGB(255, 0, 71, 132)));
return SafeArea(
child: Scaffold(
key: _scaffoldKey, // Assign the key to the Scaffold
// backgroundColor: const Color.fromARGB(255, 246, 248, 252),
// backgroundColor: Color.fromARGB(255, 255, 242, 0.92),
appBar: AppBar(
automaticallyImplyLeading: false,
title: isSearchClickd
? Container(
height: 40,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(5.0)),
child: TextField(
controller: _searchController,
onChanged: (value) {
setState(() {});
},
decoration: InputDecoration(
fillColor: Constants.k2color,
contentPadding: EdgeInsets.symmetric(vertical: 9.0),
border: OutlineInputBorder(),
hintText: "Search",
// labelText: ' Search',
prefixIcon: Icon(
Icons.search,
),
),
),
)
: Text("Offline Contacts"),
actions: [
IconButton(
onPressed: () {
setState(() {
isSearchClickd = !isSearchClickd;
if (!isSearchClickd) {
_searchController.clear();
}
});
},
icon: Icon(isSearchClickd ? Icons.close : Icons.search))
],
),
endDrawer: Drawer(
//width: MediaQuery.of(context).size.width * 99.2,
child: listdata(),
),
body:
// ListView.builder(
// itemCount: offlinekoldata.length,
// itemBuilder: (context, index) {
// var data11 = offlinekoldata[index];
// print("Imammmm_data111: $data11");
// return ListTile(
// title: Text("dd ${data11.name}"),
// );
// })
Consumer<hcpProvider>(
builder: (context, hcpProvider, child) {
print("_selectedValueConsumerConsumer_isss: $_selectedValue");
if (_selectedValue.isNotEmpty) {
_searchController.text = _selectedValue;
}
// displayedHCPList = hcpProvider.searchHCP(_searchController.text);
// offlinekoldata = HiveFunctions.OfflineStored_getindexUser(
// _searchController.text);
// where((hcp) =>
// hcp['name'].toLowerCase().contains(query.toLowerCase())
offlinekoldata = offlinekoldata
.where((element) =>
element.name
.toLowerCase()
.contains(_searchController.text.toLowerCase()) ||
element.speciality
.toLowerCase()
.contains(_searchController.text.toLowerCase()) ||
element.addr
.toLowerCase()
.contains(_searchController.text.toLowerCase()))
.toList();
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
//mainAxisSize: MainAxisSize.min,
children: [
// _switchValue
// ? const Text(
// 'All',
// style: TextStyle(
// fontSize: 12,
// decoration: TextDecoration.lineThrough,
// decorationThickness: 0.85,
// ),
// )
// : const Text(
// 'All',
// style: TextStyle(
// fontSize: 12,
// ),
// ),
Container(
child: Wrap(
children: [
Padding(
padding:
const EdgeInsets.only(left: 8.0, right: 2.0),
child: CupertinoSwitch(
activeColor: Color.fromARGB(255, 0, 71, 132),
value: _switchValue,
onChanged: (value) {
setState(() {
_switchValue = value;
});
},
),
),
Padding(
padding:
const EdgeInsets.only(right: 8.0, top: 9.0),
child: !_switchValue
? Text1(
title: 'My Contacts',
txtfont: 15,
txtcolor: Colors.grey,
)
// Text(
// 'My Contacts',
// style: TextStyle(
// fontSize: 15, color: Colors.grey),
// )
: Text1(
title: 'My Contacts',
txtfont: 15,
txtcolor: Colors.grey,
)
// const Text(
// 'My Contacts',
// style: TextStyle(
// fontSize: 15,
// ),
// ),
)
],
),
),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Row(
children: [
Text1(title: 'My Filters'),
IconButton(
onPressed: () {
retrievekol();
retrieveAffiliations();
retrievePublications();
retrieveEventss();
retrieveTrials();
_scaffoldKey.currentState?.openEndDrawer();
},
icon: Icon(
Icons.sort,
size: 30,
)),
],
),
)
],
),
// Row(
// children: [
// Expanded(
// child: Text(
// _switchValue ? "My Contacts" : "All Contacts",
// textAlign: TextAlign.center,
// style: TextStyle(
// fontSize: 20.0,
// fontWeight: FontWeight.w500,
// ),
// ),
// ),
// ],
// ),
// Padding(
// padding: const EdgeInsets.only(
// top: 8.0, bottom: 8.0, left: 20.0, right: 20.0),
// child: Center(
// child: TextField(
// controller: _searchController,
// onChanged: (value) {
// setState(() {});
// },
// decoration: InputDecoration(
// fillColor: Constants.k2color,
// contentPadding: EdgeInsets.symmetric(vertical: 9.0),
// border: OutlineInputBorder(),
// labelText: ' Search',
// prefixIcon: Icon(
// Icons.search,
// ),
// ),
// ),
// ),
// ),
SizedBox(
height: 5,
),
!_switchValue
? Expanded(
child: ListView.builder(
itemCount: offlinekoldata.length,
itemBuilder: (BuildContext context, int index) {
var data = offlinekoldata[index];
print(
"CheckinggggImage_pathOffline: ${data.img_path}");
return Column(
children: [
ListTile(
onLongPress: () {
print("LongPresss");
setState(() {
longpress = true;
});
},
onTap: () async {
print("Check_data11123 = ${data.name}");
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
SavedNewProfile1(text: data),
),
);
},
leading: data.img_path == ""
? ProfilePicture(
name: data.name,
radius: 30,
fontsize: 12,
)
: ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(30),
child: CachedNetworkImage(
imageUrl: data.img_path,
imageBuilder:
(context, imageProvider) =>
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.fill,
),
),
),
// placeholder: (context, url) =>
// CircularProgressIndicator(),
// errorWidget: (context, url, error) =>
// Icon(Icons.error),
),
),
),
trailing: Visibility(
visible: longpress,
child: Checkbox(
value: _selectedIndices
.contains(data.id.toString()),
onChanged: (value) {
// setState(() {
// _selectedIndices.add(data["id"]);
// // isChecked = value!;
// });
setState(() {
if (value!) {
_selectedIndices
.add(data.id.toString());
} else {
_selectedIndices
.remove(data.id.toString());
}
print(
"id_total123: ${_selectedIndices}");
});
}),
),
title: Text1(
title: data.name,
fontweight: FontWeight.bold,
txtfont: isTablet ? 22 : 16,
),
// Text(
// "${data["name"]}",
// style: TextStyle(
// fontSize: isTablet ? 22 : 16,
// fontWeight: FontWeight.bold,
// ),
// ),
subtitle: Column(
children: [
Row(
children: [
Expanded(
child: Text1(
title: data.speciality ??
data['spl'],
fontweight: FontWeight.normal,
txtfont: isTablet ? 20 : 14,
),
// Text(
// "${data["speciality"] ?? data['spl']},",
// style: TextStyle(
// fontSize: isTablet ? 20 : 14,
// fontWeight: FontWeight.normal,
// ),
// ),
),
],
),
Row(
children: [
Text1(
title: data.name ?? '',
fontweight: FontWeight.normal,
txtfont: 14,
),
// Text(
// "${data["State"] ?? ""},",
// style: const TextStyle(
// fontSize: 14.0,
// fontWeight: FontWeight.normal,
// ),
// ),
SizedBox(
width: 3.0,
),
Expanded(
child: Text1(
title: data.name ?? '',
fontweight: FontWeight.normal,
txtfont: 14,
),
// Text(
// "${data["Country"] ?? ""}",
// style: const TextStyle(
// fontSize: 14.0,
// fontWeight: FontWeight.normal,
// ),
// ),
),
],
),
// Row(
// children: [
// Text(
// "Added by Pooja k\nAdded on 01/07/2023",
// style: const TextStyle(
// fontSize: 12.0,
// fontWeight: FontWeight.normal,
// ),
// )
// ],
// )
],
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: EdgeInsets.only(left: 10.0),
child: Text1(
title: "Added by Pooja k",
fontweight: FontWeight.normal,
txtfont: 14,
),
),
Padding(
padding: EdgeInsets.only(right: 10.0),
child: Text1(
title: "Added on 01/07/2023",
fontweight: FontWeight.normal,
txtfont: 14,
),
)
],
),
Divider(),
],
);
},
),
)
: Expanded(
child: ListView.builder(
itemCount: HiveFunctions.getAllUsers11().length,
itemBuilder: (BuildContext context, int index) {
var data = HiveFunctions.getAllUsers11()[index];
print("CheckinggggImage_path: ${data['img_path']}");
print(
"CheckinggggImage_path: ${data['name']},${data['inid']}");
return Column(
children: [
ListTile(
onLongPress: () {
print("LongPresss");
setState(() {
longpressmy = true;
});
},
onTap: () async {
print("Check_data12345 = $data");
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// NewProfile1(text: data),
// ),
// );
},
leading: data["img_path"] == ""
? ProfilePicture(
name: data["name"],
radius: 30,
fontsize: 12,
)
: ClipOval(
child: SizedBox.fromSize(
size: Size.fromRadius(30),
child: CachedNetworkImage(
imageUrl: data["img_path"],
imageBuilder:
(context, imageProvider) =>
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider,
fit: BoxFit.fill,
),
),
),
// placeholder: (context, url) =>
// CircularProgressIndicator(),
// errorWidget: (context, url, error) =>
// Icon(Icons.error),
),
),
),
trailing: Visibility(
visible: longpressmy,
child: Checkbox(
value: _selectedremoveIndices
.contains(data["id"]),
onChanged: (value) {
setState(() {
if (value!) {
_selectedremoveIndices
.add(data["id"]);
} else {
_selectedremoveIndices
.remove(data["id"]);
}
print(
"id_total: ${_selectedremoveIndices}");
});
}),
),
title: Text(
"${data["name"]}",
style: TextStyle(
fontSize: isTablet ? 22 : 16,
fontWeight: FontWeight.bold,
),
),
subtitle: Column(
children: [
Row(
children: [
Expanded(
child: Text(
"${data["speciality"] ?? data['spl']},",
style: TextStyle(
fontSize: isTablet ? 20 : 14,
fontWeight: FontWeight.normal,
),
),
),
],
),
Row(
children: [
Text(
"${data["addr"]},",
style: const TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.normal,
),
),
],
),
],
),
),
const Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: EdgeInsets.only(left: 10.0),
child: Text(
"Added by Pooja k",
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.normal,
),
),
),
Padding(
padding: EdgeInsets.only(right: 10.0),
child: Text(
"Added on 01/07/2023",
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.normal,
),
),
)
],
),
Divider(),
],
);
},
),
),
!_switchValue
? Align(
alignment: Alignment.bottomCenter,
child: longpress
? Container(
color: const Color.fromARGB(255, 251, 242, 242),
width: MediaQuery.of(context).size.width,
height: 200.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () async {
print("Selected: ${_selectedIndices}");
print(
"Selected: ${_selectedIndices.length}");
for (int i = 0;
i < _selectedIndices.length;
i++) {
// print(
// 'The id id : ${_selectedIndices[i]}');
// //List<_Row> _rows = [];
// final row = displayedHCPList[
// _selectedIndices[i] - 1];
// var data = displayedHCPList[i];
// print(
// "checking_value_istrends: ${_selectedIndices[i]},${row["name"]}, ${row["id"]}");
// int autoIncrementKey1 =
// await getNextAutoIncrementValue();
// print(autoIncrementKey1);
// HiveFunctions.createUser({
// "inid": autoIncrementKey1,
// "id": autoIncrementKey1,
// "name": row["name"],
// "org": "med",
// "addr": row["addr"],
// "phone": row["phone_no"],
// "phone_no": row["phone_no"],
// "email": row["email"],
// "summarry": row["summarry"],
// "speciality": row["speciality"],
// "sub_speciality":
// row["sub_speciality"],
// "img_path": row["img_path"],
// });
}
_showMyDialog(
"Selected contact has been added to my contacts ");
},
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.add,
color: Colors.green,
),
),
Text(
'Add to My Contacts',
style: TextStyle(
color: Colors.black,
fontSize: 14.0),
),
],
),
),
Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.download,
color: Colors.blue,
),
),
GestureDetector(
onTap: () {},
child: Text(
'Download',
style:
TextStyle(color: Colors.black),
),
),
],
),
GestureDetector(
onTap: () {
setState(() {
longpress = false;
_selectedIndices.clear();
_selectedremoveIndices.clear();
});
},
child: const Row(
children: [
Padding(
padding: EdgeInsets.all(15.0),
child: Icon(
Icons.close,
color: Colors.red,
),
),
Text(
'Cancel',
style:
TextStyle(color: Colors.black),
),
],
),
),
Expanded(
child: GestureDetector(
onTap: () async {
print(
"Selected: ${_selectedIndices}");
for (int i = 0;
i < _selectedIndices.length;
i++) {
print(
'The id id : ${_selectedIndices[i]}');
// Map<String, dynamic>? row =
// findRecordById(offlinekoldata,
// _selectedIndices[i]);
// print("Storingggg_isss:Row $row");
// print(
// "checking_Deleted_istrends: ${_selectedIndices[i]},${row!["license_no"]}, ${row["email"]}, ${row["img_path"]} ");
await deletekol(
_selectedIndices[i]);
_showMyDialog(
"selected contact has been removed");
}
// print(
// "CheckingAfflist: $affilist");
setState(() {});
},
child: const Row(
children: [
Padding(
padding: EdgeInsets.all(15.0),
child: Icon(
Icons.save,
color: Colors.deepOrange,
),
),
Padding(
padding:
EdgeInsets.only(top: 15.0),
child: Text(
'Delete Offline',
style: TextStyle(
color: Colors.black),
),
),
],
),
),
),
],
),
)
: Container(),
)
: Align(
alignment: Alignment.bottomCenter,
child: longpressmy
? Container(
color: const Color.fromARGB(255, 251, 242, 242),
width: MediaQuery.of(context).size.width,
height: 200.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () async {
print(
"SelectedRemoveee: ${_selectedremoveIndices}");
print(
"Selected: ${_selectedremoveIndices.length}");
for (int i = 0;
i < _selectedremoveIndices.length;
i++) {
print(
'The id id : ${_selectedremoveIndices[i]}');
//List<_Row> _rows = [];
// final row = displayedHCPList[
// _selectedremoveIndices[i] - 1];
// var data = displayedHCPList[i];
final row =
await HiveFunctions.getuser(
_selectedremoveIndices[i]);
// var data = HiveFunctions.getuser()[i];
print("Delete_Row ${row[i]}");
print("Delete_Row ${row[i]["inid"]}");
// print(
// "checking_valueRemove_istrends: ${_selectedremoveIndices[i]},${row["name"]}, ${row["id"]},${row["inid"]}");
//HiveFunctions.addno(_selectedIndices[i]);
// HiveFunctions.removeno(_selectedremoveIndices[i]);
final row1 =
await HiveFunctions.deleteUser11(
row[i]["inid"]);
setState(() {});
// HiveFunctions.deleteUser(_selectedremoveIndices);
}
_showMyDialog(
"selected contact has been removed");
},
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.remove,
color: Colors.green,
),
),
Text(
'Remove from My Contacts',
style:
TextStyle(color: Colors.black),
),
],
),
),
Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.download,
color: Colors.blue,
),
),
GestureDetector(
onTap: () {},
child: Text(
'Download',
style:
TextStyle(color: Colors.black),
),
),
],
),
GestureDetector(
onTap: () {
setState(() {
longpressmy = false;
_selectedIndices.clear();
_selectedremoveIndices.clear();
});
},
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(15.0),
child: Icon(
Icons.close,
color: Colors.red,
),
),
Text(
'Cancel',
style: TextStyle(
color: Constants.k2color),
),
],
),
),
],
),
)
: Container(),
),
],
);
},
),
),
);
}
listdata() {
return ListView(
children: <Widget>[
// DrawerHeader removed
ListTile(
title: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Icon(
Icons.sort,
size: 30.0,
),
const Text(
"Filters",
style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold),
),
GestureDetector(
onTap: () {
Navigator.pop(context);
// print("hiii");
},
child: const Icon(Icons.cancel))
],
),
),
),
ListTile(
title: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
OutlinedButton(
onPressed: () {
//setState(() {});
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SavedContacts1()),
).then((value) => setState(() {}));
print("refresh done ");
// })
},
child: Text(
'Reset Filter',
style: TextStyle(color: Constants.k2color),
),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
],
),
),
ListTile(
title: DropdownButtonHideUnderline(
child: DropdownButtonFormField2<String>(
hint: Text("Select the Type"),
decoration: InputDecoration(
// Add Horizontal padding using menuItemStyleData.padding so it matches
// the menu padding when button's width is not specified.
isDense: true,
contentPadding: const EdgeInsets.symmetric(vertical: 9),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
// Add more decoration..
),
isExpanded: true,
value: _selectedValue1,
items: items.map((String item) {
return DropdownMenuItem<String>(
value: item,
child: Text(item),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
_selectedValue1 = newValue;
});
},
buttonStyleData: const ButtonStyleData(
padding: EdgeInsets.symmetric(horizontal: 16),
height: 50,
width: 200,
),
dropdownStyleData: DropdownStyleData(
maxHeight: 200,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
),
),
menuItemStyleData: const MenuItemStyleData(
height: 40,
),
dropdownSearchData: DropdownSearchData(
searchController: textEditingController,
searchInnerWidgetHeight: 50,
searchInnerWidget: Container(
height: 50,
// padding: const EdgeInsets.only(
// top: 8,
// bottom: 4,
// right: 8,
// left: 8,
// ),
child: TextFormField(
expands: true,
maxLines: null,
controller: textEditingController,
decoration: InputDecoration(
isDense: true,
contentPadding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 18,
),
hintText: 'Search for an item...',
hintStyle: const TextStyle(fontSize: 12),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
searchMatchFn: (item, searchValue) {
final itemString = item.value.toString().toLowerCase();
final searchString = searchValue.toLowerCase();
return itemString.contains(searchString);
},
),
onMenuStateChange: (isOpen) {
if (!isOpen) {
textEditingController.clear();
}
},
iconStyleData: IconStyleData(
icon: Icon(Icons.arrow_drop_down),
iconSize: 20,
),
),
),
),
ListTile(
title: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black),
borderRadius: BorderRadius.circular(10)),
child: Padding(
padding: const EdgeInsets.all(3.5),
child: DropDownField(
hintText: 'Select an option',
items: ddlist,
onValueChanged: (newValue) {
setState(() {
_selectedValue = newValue;
});
},
value: _selectedValue,
),
),
),
),
// ListTile(
// title: Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// OutlinedButton(
// onPressed: () {
// setState(() {});
// print("refresh done 111");
// },
// child: Text(
// 'Saved Profiles',
// style: TextStyle(color: Constants.k2color),
// ),
// style: OutlinedButton.styleFrom(
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(12),
// ),
// ),
// ),
// ],
// ),
// ),
],
);
}
filterss(String selectedValue) async {
setState(() {
print("_selectedValue_isss: $_selectedValue");
});
}
Future<void> _showMyDialog(String data) async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Successfully'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
// Text('This is a demo alert dialog.'),
Text(data),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Ok'),
onPressed: () {
Navigator.of(context).pop();
setState(() {
_selectedIndices.clear();
_selectedremoveIndices.clear();
longpress = false;
longpressmy = false;
});
},
),
],
);
},
);
}
Future<int> getNextAutoIncrementValue() async {
var counterBox = await Hive.openBox<int>('counterBox');
if (!counterBox.containsKey('counter')) {
counterBox.put('counter', 0);
}
int? counter = counterBox.get('counter');
counterBox.put('counter', counter! + 1);
await counterBox.close();
return counter;
}
Map<String, dynamic> findRecordById(
List displayedHCPList, String selectedIndic) {
// print(
// "Gettt11111 ${displayedHCPList.firstWhere((element) => element['id'] == int.parse(selectedIndic))}");
return displayedHCPList
.firstWhere((element) => element['id'] == int.parse(selectedIndic));
}
}