From d575d5fb8bfd70ff08cc1064cf5c0711faedd35e Mon Sep 17 00:00:00 2001 From: rishabh7923 Date: Sun, 20 Oct 2024 10:51:35 +0530 Subject: [PATCH] Fixed Scrolling Issue in Hyperledger --- lib/programs screen/hyperledger.dart | 201 ++++++++++++++------------- 1 file changed, 102 insertions(+), 99 deletions(-) diff --git a/lib/programs screen/hyperledger.dart b/lib/programs screen/hyperledger.dart index 0390384..3a3b0a1 100644 --- a/lib/programs screen/hyperledger.dart +++ b/lib/programs screen/hyperledger.dart @@ -29,28 +29,28 @@ class _HyperledgerState extends State { late Future getProjectFunction; Future initializeProjectLists() async { - var response = - await rootBundle.loadString('assets/projects/hyperledger/hyperledger2024.json'); + var response = await rootBundle + .loadString('assets/projects/hyperledger/hyperledger2024.json'); var jsonList = await json.decode(response); for (var data in jsonList) { hyperledger2024.add(HyperledgerProjectModal.fromJson(data)); } projectList = hyperledger2024; print(projectList); - response = - await rootBundle.loadString('assets/projects/hyperledger/hyperledger2023.json'); + response = await rootBundle + .loadString('assets/projects/hyperledger/hyperledger2023.json'); jsonList = await json.decode(response); for (var data in jsonList) { hyperledger2023.add(HyperledgerProjectModal.fromJson(data)); } - response = - await rootBundle.loadString('assets/projects/hyperledger/hyperledger2022.json'); + response = await rootBundle + .loadString('assets/projects/hyperledger/hyperledger2022.json'); jsonList = await json.decode(response); for (var data in jsonList) { hyperledger2022.add(HyperledgerProjectModal.fromJson(data)); } - response = - await rootBundle.loadString('assets/projects/hyperledger/hyperledger2021.json'); + response = await rootBundle + .loadString('assets/projects/hyperledger/hyperledger2021.json'); jsonList = await json.decode(response); for (var data in jsonList) { hyperledger2021.add(HyperledgerProjectModal.fromJson(data)); @@ -154,7 +154,8 @@ class _HyperledgerState extends State { onPressed: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => const HYPERLEDGERInfo()), + MaterialPageRoute( + builder: (context) => const HYPERLEDGERInfo()), ); }, ), @@ -168,12 +169,9 @@ class _HyperledgerState extends State { } else if (snapshot.hasError) { return Center(child: Text("Error: ${snapshot.error}")); } else if (snapshot.connectionState == ConnectionState.done) { - return Padding( - padding: EdgeInsets.symmetric( - horizontal: ScreenUtil().setWidth(46), - vertical: ScreenUtil().setHeight(16), - ), - child: SingleChildScrollView( + return SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 46, vertical: 16), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -184,19 +182,23 @@ class _HyperledgerState extends State { suffixIcon: const Icon(Icons.search), enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide(color: Color(0xFFEEEEEE)), + borderSide: + const BorderSide(color: Color(0xFFEEEEEE)), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide(color: Color(0xFFEEEEEE)), + borderSide: + const BorderSide(color: Color(0xFFEEEEEE)), ), disabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide(color: Color(0xFFEEEEEE)), + borderSide: + const BorderSide(color: Color(0xFFEEEEEE)), ), border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), - borderSide: const BorderSide(color: Color(0xFFEEEEEE)), + borderSide: + const BorderSide(color: Color(0xFFEEEEEE)), ), contentPadding: EdgeInsets.symmetric( vertical: ScreenUtil().setHeight(12), @@ -213,89 +215,90 @@ class _HyperledgerState extends State { }, ), SizedBox(height: ScreenUtil().setHeight(20)), - SizedBox( - height: MediaQuery.of(context).size.height * 0.25, - child: GridView( - physics: const NeverScrollableScrollPhysics(), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - childAspectRatio: 1.5 / 0.6, - crossAxisCount: 2, - crossAxisSpacing: 15, - mainAxisSpacing: 15, + Container( + constraints: BoxConstraints( + maxHeight: MediaQuery.sizeOf(context).height * 0.2, ), - children: [ - YearButton( - year: "2024", - isEnabled: selectedYear == 2024, - onTap: () { - setState(() { - projectList = hyperledger2024; - selectedYear = 2024; - }); - }, - backgroundColor: selectedYear == 2024 - ? Colors.white - : const Color.fromRGBO(255, 183, 77, 1), - ), - YearButton( - year: "2023", - isEnabled: selectedYear == 2023, - onTap: () { - setState(() { - projectList = hyperledger2023; - selectedYear = 2023; - }); - }, - backgroundColor: selectedYear == 2023 - ? Colors.white - : const Color.fromRGBO(255, 183, 77, 1), - ), - YearButton( - year: "2022", - isEnabled: selectedYear == 2022, - onTap: () { - setState(() { - projectList = hyperledger2022; - selectedYear = 2022; - }); - }, - backgroundColor: selectedYear == 2022 - ? Colors.white - : const Color.fromRGBO(255, 183, 77, 1), + width: MediaQuery.sizeOf(context).width, + child: GridView( + physics: const NeverScrollableScrollPhysics(), + gridDelegate: + const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + childAspectRatio: 1.5 / 0.6, + crossAxisSpacing: 15, + mainAxisSpacing: 15, ), - YearButton( - year: "2021", - isEnabled: selectedYear == 2021, - onTap: () { - setState(() { - projectList = hyperledger2021; - selectedYear = 2021; - }); - }, - backgroundColor: selectedYear == 2021 - ? Colors.white - : const Color.fromRGBO(255, 183, 77, 1), - ), - ], - ), - ), - SizedBox(height: ScreenUtil().setHeight(20)), - SizedBox( - height: MediaQuery.of(context).size.height * 0.6, - child: ListView.builder( - itemCount: projectList.length, - itemBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: HyperledgerProjectWidget( - modal: projectList[index], - height: ScreenUtil().screenHeight * 0.2, - width: ScreenUtil().screenWidth, - index: index+1, + children: [ + YearButton( + year: "2024", + isEnabled: selectedYear == 2024, + onTap: () { + setState(() { + projectList = hyperledger2024; + selectedYear = 2024; + }); + }, + backgroundColor: selectedYear == 2024 + ? Colors.white + : const Color.fromRGBO(255, 183, 77, 1), ), - ); - }, - ), + YearButton( + year: "2023", + isEnabled: selectedYear == 2023, + onTap: () { + setState(() { + projectList = hyperledger2023; + selectedYear = 2023; + }); + }, + backgroundColor: selectedYear == 2023 + ? Colors.white + : const Color.fromRGBO(255, 183, 77, 1), + ), + YearButton( + year: "2022", + isEnabled: selectedYear == 2022, + onTap: () { + setState(() { + projectList = hyperledger2022; + selectedYear = 2022; + }); + }, + backgroundColor: selectedYear == 2022 + ? Colors.white + : const Color.fromRGBO(255, 183, 77, 1), + ), + YearButton( + year: "2021", + isEnabled: selectedYear == 2021, + onTap: () { + setState(() { + projectList = hyperledger2021; + selectedYear = 2021; + }); + }, + backgroundColor: selectedYear == 2021 + ? Colors.white + : const Color.fromRGBO(255, 183, 77, 1), + ) + ], + )), + ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: projectList.length, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: HyperledgerProjectWidget( + modal: projectList[index], + height: ScreenUtil().screenHeight * 0.2, + width: ScreenUtil().screenWidth, + index: index + 1, + ), + ); + }, ), ], ),