From 7db4700353bc1c73aad1cae1fb466bfcea23fb99 Mon Sep 17 00:00:00 2001 From: Dakshesh42 Date: Tue, 6 Aug 2024 19:17:36 +0530 Subject: [PATCH] community tab error fixed --- .../Community/Model/FeedPostModel.dart | 341 +++++++++--------- .../Community_HomePage/Community.dart | 163 +++++---- .../View/Individual/step2Selectactivity.dart | 1 + pubspec.yaml | 11 +- 4 files changed, 277 insertions(+), 239 deletions(-) diff --git a/lib/Main_Screens/Community/Model/FeedPostModel.dart b/lib/Main_Screens/Community/Model/FeedPostModel.dart index ffb9bc5..7315185 100644 --- a/lib/Main_Screens/Community/Model/FeedPostModel.dart +++ b/lib/Main_Screens/Community/Model/FeedPostModel.dart @@ -1,197 +1,212 @@ class FeedPostModel { - FeedPostModel({ - required this.status, - required this.statusCode, - required this.message, - required this.data, - }); + FeedPostModel({ + required this.status, + required this.statusCode, + required this.message, + required this.data, + }); - final String? status; - final int? statusCode; - final String? message; - final Data? data; - - factory FeedPostModel.fromJson(Map json){ - return FeedPostModel( - status: json["status"], - statusCode: json["status_code"], - message: json["message"], - data: json["data"] == null ? null : Data.fromJson(json["data"]), - ); - } + final String? status; + final int? statusCode; + final String? message; + final Data? data; + factory FeedPostModel.fromJson(Map json) { + return FeedPostModel( + status: json["status"], + statusCode: json["status_code"], + message: json["message"], + data: json["data"] == null ? null : Data.fromJson(json["data"]), + ); + } } class Data { - Data({ - required this.pinnedCommunityPost, - required this.pinnedUserPost, - required this.pinnedTagsPost, - }); + Data({ + required this.pinnedCommunityPost, + required this.pinnedUserPost, + required this.pinnedTagsPost, + }); - final List pinnedCommunityPost; - final List pinnedUserPost; - final List pinnedTagsPost; - - factory Data.fromJson(Map json){ - return Data( - pinnedCommunityPost: json["pinned_community_post"] == null ? [] : List.from(json["pinned_community_post"]!.map((x) => PinnedPost.fromJson(x))), - pinnedUserPost: json["pinned_user_post"] == null ? [] : List.from(json["pinned_user_post"]!.map((x) => PinnedPost.fromJson(x))), - pinnedTagsPost: json["pinned_tags_post"] == null ? [] : List.from(json["pinned_tags_post"]!.map((x) => PinnedPost.fromJson(x))), - ); - } + final List pinnedCommunityPost; + final List pinnedUserPost; + final List pinnedTagsPost; + factory Data.fromJson(Map json) { + return Data( + pinnedCommunityPost: json["pinned_community_post"] == null + ? [] + : List.from(json["pinned_community_post"]! + .map((x) => PinnedPost.fromJson(x))), + pinnedUserPost: json["pinned_user_post"] == null + ? [] + : List.from( + json["pinned_user_post"]!.map((x) => PinnedPost.fromJson(x))), + // pinnedTagsPost: json["pinned_tags_post"] == null ? [] : List.from(json["pinned_tags_post"]!.map((x) => PinnedPost.fromJson(x))), + pinnedTagsPost: json["pinned_tags_post"] == null + ? [] + : List.from(json["pinned_tags_post"]! + .expand((x) => x as List) + .map((x) => PinnedPost.fromJson(x))), + ); + } } class PinnedPost { - PinnedPost({ - required this.id, - required this.likecount, - required this.tagsXid, - required this.isILiked, - required this.totalComment, - required this.totalSave, - required this.iamPrincipalXid, - required this.postIn, - required this.caption, - required this.image, - required this.manageTagsXids, - required this.postAs, - required this.ctaTitle, - required this.ctaLink, - required this.createdAt, - required this.tagNames, - required this.likeIcon, - required this.iamPrincipal, - required this.community, - }); + PinnedPost({ + required this.id, + required this.likecount, + required this.tagsXid, + required this.isILiked, + required this.totalComment, + required this.totalSave, + required this.iamPrincipalXid, + required this.postIn, + required this.caption, + required this.image, + required this.manageTagsXids, + required this.postAs, + required this.ctaTitle, + required this.ctaLink, + required this.createdAt, + required this.tagNames, + required this.likeIcon, + required this.iamPrincipal, + required this.community, + }); - final int? id; - final int? likecount; - final List tagsXid; - final bool? isILiked; - final int? totalComment; - final int? totalSave; - final int? iamPrincipalXid; - final int? postIn; - final String? caption; - final String? image; - final String? manageTagsXids; - final String? postAs; - final String? ctaTitle; - final String? ctaLink; - final DateTime? createdAt; - final List tagNames; - final LikeIcon? likeIcon; - final IamPrincipal? iamPrincipal; - final Community? community; - - factory PinnedPost.fromJson(Map json){ - return PinnedPost( - id: json["id"], - likecount: json["likecount"], - tagsXid: json["tags_xid"] == null ? [] : List.from(json["tags_xid"]!.map((x) => x)), - isILiked: json["is_i_liked"], - totalComment: json["total_comment"], - totalSave: json["total_save"], - iamPrincipalXid: json["iam_principal_xid"], - postIn: json["post_in"], - caption: json["caption"], - image: json["image"], - manageTagsXids: json["manage_tags_xids"], - postAs: json["post_as"], - ctaTitle: json["cta_title"], - ctaLink: json["cta_link"], - createdAt: DateTime.tryParse(json["created_at"] ?? ""), - tagNames: json["tag_names"] == null ? [] : List.from(json["tag_names"]!.map((x) => x)), - likeIcon: json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), - iamPrincipal: json["iam_principal"] == null ? null : IamPrincipal.fromJson(json["iam_principal"]), - community: json["community"] == null ? null : Community.fromJson(json["community"]), - ); - } + final int? id; + final int? likecount; + final List tagsXid; + final bool? isILiked; + final int? totalComment; + final int? totalSave; + final int? iamPrincipalXid; + final int? postIn; + final String? caption; + final String? image; + final String? manageTagsXids; + final String? postAs; + final String? ctaTitle; + final String? ctaLink; + final DateTime? createdAt; + final List tagNames; + final LikeIcon? likeIcon; + final IamPrincipal? iamPrincipal; + final Community? community; + factory PinnedPost.fromJson(Map json) { + return PinnedPost( + id: json["id"], + likecount: json["likecount"], + tagsXid: json["tags_xid"] == null + ? [] + : List.from(json["tags_xid"]!.map((x) => x)), + isILiked: json["is_i_liked"], + totalComment: json["total_comment"], + totalSave: json["total_save"], + iamPrincipalXid: json["iam_principal_xid"], + postIn: json["post_in"], + caption: json["caption"], + image: json["image"], + manageTagsXids: json["manage_tags_xids"], + postAs: json["post_as"], + ctaTitle: json["cta_title"], + ctaLink: json["cta_link"], + createdAt: DateTime.tryParse(json["created_at"] ?? ""), + tagNames: json["tag_names"] == null + ? [] + : List.from(json["tag_names"]!.map((x) => x)), + likeIcon: + json["likeIcon"] == null ? null : LikeIcon.fromJson(json["likeIcon"]), + iamPrincipal: json["iam_principal"] == null + ? null + : IamPrincipal.fromJson(json["iam_principal"]), + community: json["community"] == null + ? null + : Community.fromJson(json["community"]), + ); + } } class Community { - Community({ - required this.id, - required this.communityProfilePhoto, - required this.communityName, - }); + Community({ + required this.id, + required this.communityProfilePhoto, + required this.communityName, + }); - final int? id; - final String? communityProfilePhoto; - final String? communityName; - - factory Community.fromJson(Map json){ - return Community( - id: json["id"], - communityProfilePhoto: json["community_profile_photo"], - communityName: json["community_name"], - ); - } + final int? id; + final String? communityProfilePhoto; + final String? communityName; + factory Community.fromJson(Map json) { + return Community( + id: json["id"], + communityProfilePhoto: json["community_profile_photo"], + communityName: json["community_name"], + ); + } } class IamPrincipal { - IamPrincipal({ - required this.id, - required this.principalTypeXid, - required this.userName, - required this.fullName, - required this.profilePhoto, - }); + IamPrincipal({ + required this.id, + required this.principalTypeXid, + required this.userName, + required this.fullName, + required this.profilePhoto, + }); - final int? id; - final int? principalTypeXid; - final String? userName; - final String? fullName; - final String? profilePhoto; - - factory IamPrincipal.fromJson(Map json){ - return IamPrincipal( - id: json["id"], - principalTypeXid: json["principal_type_xid"], - userName: json["user_name"], - fullName: json["full_name"], - profilePhoto: json["profile_photo"], - ); - } + final int? id; + final int? principalTypeXid; + final String? userName; + final String? fullName; + final String? profilePhoto; + factory IamPrincipal.fromJson(Map json) { + return IamPrincipal( + id: json["id"], + principalTypeXid: json["principal_type_xid"], + userName: json["user_name"], + fullName: json["full_name"], + profilePhoto: json["profile_photo"], + ); + } } class LikeIcon { - LikeIcon({ - required this.likeIconsXid, - required this.likeIcon, - }); + LikeIcon({ + required this.likeIconsXid, + required this.likeIcon, + }); - final int? likeIconsXid; - final LikeIconClass? likeIcon; - - factory LikeIcon.fromJson(Map json){ - return LikeIcon( - likeIconsXid: json["like_icons_xid"], - likeIcon: json["like_icon"] == null ? null : LikeIconClass.fromJson(json["like_icon"]), - ); - } + final int? likeIconsXid; + final LikeIconClass? likeIcon; + factory LikeIcon.fromJson(Map json) { + return LikeIcon( + likeIconsXid: json["like_icons_xid"], + likeIcon: json["like_icon"] == null + ? null + : LikeIconClass.fromJson(json["like_icon"]), + ); + } } class LikeIconClass { - LikeIconClass({ - required this.id, - required this.image, - }); + LikeIconClass({ + required this.id, + required this.image, + }); - final int? id; - final String? image; - - factory LikeIconClass.fromJson(Map json){ - return LikeIconClass( - id: json["id"], - image: json["image"], - ); - } + final int? id; + final String? image; + factory LikeIconClass.fromJson(Map json) { + return LikeIconClass( + id: json["id"], + image: json["image"], + ); + } } diff --git a/lib/Main_Screens/Community_HomePage/Community.dart b/lib/Main_Screens/Community_HomePage/Community.dart index 4e8ef80..460f2ad 100644 --- a/lib/Main_Screens/Community_HomePage/Community.dart +++ b/lib/Main_Screens/Community_HomePage/Community.dart @@ -241,75 +241,102 @@ class _FeedTabState extends State { fit: BoxFit.fill), ), ), - Column( - children: [ - sizedBoxHeight(16.h), - Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: combinedList.length, - itemBuilder: (context, index) { - var timeAgo = ConvertServerDateToUserDate() - .convertServerDateToReadableFormate( - combinedList[index].createdAt.toString()); - if (index == 1) { - return announcecardtile( - profileImg: combinedList[index] - .iamPrincipal! - .profilePhoto ?? - '', - title: combinedList[index].iamPrincipal!.fullName ?? - '', - mainImg: combinedList[index].image ?? '', - containerTitle: - combinedList[index].tagNames ?? [''], - create_at: timeAgo, - community_name: - combinedList[index].community!.communityName ?? - '', - totalcomments: - combinedList[index].totalComment.toString(), - description: combinedList[index].caption ?? '', - totalSave: combinedList[index].totalSave.toString(), - ); - } else { - return Column( - children: [ - normalcardtile2( - profileImg: combinedList[index] - .iamPrincipal! - .profilePhoto ?? - '', - title: combinedList[index] - .iamPrincipal! - .fullName ?? - '', - mainImg: combinedList[index].image ?? '', - containerTitle: - combinedList[index].tagNames ?? [], - description: combinedList[index].caption ?? '', - create_at: timeAgo, - total_comments: - combinedList[index].totalComment.toString(), - total_likes: - combinedList[index].likecount.toString(), - total_save: - combinedList[index].totalSave.toString(), - community_name: combinedList[index] - .community! - .communityName - .toString(), - RecationId: combinedList[index].id.toString(), - ), - sizedBoxHeight(20.h) - ], - ); - } - }, + combinedList.isEmpty + ? Expanded( + child: Center( + child: Column( + children: [ + Text( + "No Data Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ), + ) + : Column( + children: [ + sizedBoxHeight(16.h), + Expanded( + child: ListView.builder( + shrinkWrap: true, + itemCount: combinedList.length, + itemBuilder: (context, index) { + var timeAgo = ConvertServerDateToUserDate() + .convertServerDateToReadableFormate( + combinedList[index].createdAt.toString()); + if (index == 1) { + return announcecardtile( + profileImg: combinedList[index] + .iamPrincipal! + .profilePhoto ?? + '', + title: combinedList[index] + .iamPrincipal! + .fullName ?? + '', + mainImg: combinedList[index].image ?? '', + containerTitle: + combinedList[index].tagNames ?? [''], + create_at: timeAgo, + community_name: combinedList[index] + .community! + .communityName ?? + '', + totalcomments: combinedList[index] + .totalComment + .toString(), + description: + combinedList[index].caption ?? '', + totalSave: + combinedList[index].totalSave.toString(), + ); + } else { + return Column( + children: [ + normalcardtile2( + profileImg: combinedList[index] + .iamPrincipal! + .profilePhoto ?? + '', + title: combinedList[index] + .iamPrincipal! + .fullName ?? + '', + mainImg: combinedList[index].image ?? '', + containerTitle: + combinedList[index].tagNames ?? [], + description: + combinedList[index].caption ?? '', + create_at: timeAgo, + total_comments: combinedList[index] + .totalComment + .toString(), + total_likes: combinedList[index] + .likecount + .toString(), + total_save: combinedList[index] + .totalSave + .toString(), + community_name: combinedList[index] + .community! + .communityName + .toString(), + RecationId: + combinedList[index].id.toString(), + ), + sizedBoxHeight(20.h) + ], + ); + } + }, + ), + ), + ], ), - ), - ], - ), ], ); } diff --git a/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart b/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart index 89c76e2..2d54159 100644 --- a/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart +++ b/lib/onboarding/Signup/View/Individual/step2Selectactivity.dart @@ -52,6 +52,7 @@ class _SelectIndividualActivityState extends State { // If the first selected container is unselected, reset the active state _firstSelectedIndex = null; _isFirstSelectionActive = false; + _selectedIndices.clear(); } } else { if (_firstSelectedIndex == null) { diff --git a/pubspec.yaml b/pubspec.yaml index 2f9ba08..e6b5a0c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: regroup description: A new Flutter project. # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: '>=2.19.6 <3.0.0' + sdk: ">=2.19.6 <3.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions @@ -31,7 +31,6 @@ dependencies: flutter: sdk: flutter - # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 @@ -48,7 +47,7 @@ dependencies: image_cropper: ^6.0.0 image_picker: ^1.0.8 lottie: ^3.1.2 - connectivity_plus: + connectivity_plus: animations: ^2.0.11 shimmer: ^3.0.0 device_info_plus: ^9.1.2 @@ -78,15 +77,12 @@ dependencies: flutter_html: ^3.0.0-beta.2 comment_tree: ^0.3.0 - - dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 - flutter_launcher_icons: ^0.13.1 flutter_launcher_icons: @@ -101,7 +97,6 @@ flutter_launcher_icons: # The following section is specific to Flutter packages. flutter: - # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class.