DiscoverModule/lib/contacts_module/ui_screen/nih_show_more.dart

110 lines
3.8 KiB
Dart
Raw Normal View History

2024-10-07 12:41:28 +00:00
// import 'package:discover_module/provider_class/nih_provider.dart';
// import 'package:discover_module/ui_screen/bottom_sheet.dart';
import 'package:discover_module/contacts_module/provider_class/nih_provider.dart';
import 'package:discover_module/contacts_module/ui_screen/bottom_sheet.dart';
2024-08-30 12:24:54 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class NIHShowMore extends StatefulWidget {
NIHShowMore({required this.text, Key? key}) : super(key: key);
final int text;
@override
State<NIHShowMore> createState() => _NIHShowMoreState();
}
class _NIHShowMoreState extends State<NIHShowMore> {
List nihgrants = [];
@override
void initState() {
// TODO: implement initState
super.initState();
affdata();
}
affdata() async {
var nih = Provider.of<NIHGrantsProvider>(context, listen: false);
await nih.nihinfo(widget.text);
final nih1 = nih.nihlist;
setState(() {
nihgrants = nih1;
});
print("locationList: ${nihgrants}");
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('NIH Grants'),
),
body: Scrollbar(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Container(
constraints:
BoxConstraints(minWidth: MediaQuery.of(context).size.width),
color: Colors.white,
child: DataTable(
showCheckboxColumn: false,
columns: const [
DataColumn(
label: Expanded(
child: Text('NIH Center',
style: TextStyle(fontWeight: FontWeight.w600),
softWrap: true),
)),
DataColumn(
label: Expanded(
child: Text('Organization Name',
style:
TextStyle(fontWeight: FontWeight.w600)))),
],
rows: List.generate(
nihgrants.length,
(index) => DataRow(
onSelectChanged: (value) {
print("message ${nihgrants[index]}");
showModalBottomSheet(
useRootNavigator: true,
isScrollControlled: false,
enableDrag: true,
useSafeArea: true,
constraints: const BoxConstraints(
maxWidth: double.infinity,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(0),
),
),
clipBehavior: Clip.antiAliasWithSaveLayer,
context: context,
builder: (context) {
return bsheet(nihgrants[index]);
},
);
},
cells: [
DataCell(Text(nihgrants[index]['pi_names'].toString(),
softWrap: true)),
DataCell(Text(
nihgrants[index]['NIH Center/Institute'].toString(),
softWrap: true)),
],
),
),
),
),
),
),
));
}
}