initalization error fixed completley
This commit is contained in:
@@ -1,30 +1,23 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_reaction_button/flutter_reaction_button.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:regroup/Common/CommonGlassmorphism.dart';
|
||||
import 'package:regroup/Common/CommonTabBar.dart';
|
||||
import 'package:regroup/Common/CommonWidget.dart';
|
||||
import 'package:regroup/Common/ConvertServerDateToUserDate.dart';
|
||||
import 'package:regroup/Common/base_manager.dart';
|
||||
import 'package:regroup/Common/controller/NormalPostCard.dart';
|
||||
import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart';
|
||||
import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart';
|
||||
import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart';
|
||||
import 'package:regroup/Main_Screens/Community/ViewModel/postmethod.dart';
|
||||
import 'package:regroup/Main_Screens/Community_HomePage/Community.dart';
|
||||
|
||||
import 'package:regroup/Main_Screens/Community_HomePage/view_model/CountersHelper.dart';
|
||||
import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitygetmethod.dart';
|
||||
import 'package:regroup/Main_Screens/Community_HomePage/view_model/communitypostmethod.dart';
|
||||
import 'package:regroup/Utils/Common/CommonAppbar.dart';
|
||||
import 'package:regroup/Utils/Common/ShimmerCommon.dart';
|
||||
import 'package:regroup/Utils/Common/sized_box.dart';
|
||||
import 'package:regroup/Utils/dialogs.dart';
|
||||
import 'package:regroup/Utils/texts.dart';
|
||||
import 'package:regroup/resources/routes/route_name.dart';
|
||||
import 'package:async/src/future_group.dart';
|
||||
|
||||
import 'package:regroup/sidemenu/view_model/postmethod.dart';
|
||||
|
||||
class TagdetailScreen extends StatefulWidget {
|
||||
@@ -130,16 +123,16 @@ class _TagdetailScreenState extends State<TagdetailScreen> {
|
||||
}
|
||||
|
||||
class PopularTab extends StatefulWidget {
|
||||
PopularTab({super.key, required this.id});
|
||||
const PopularTab({super.key, required this.id});
|
||||
|
||||
int id;
|
||||
final int id;
|
||||
|
||||
@override
|
||||
State<PopularTab> createState() => _PopularTabState();
|
||||
}
|
||||
|
||||
class _PopularTabState extends State<PopularTab> {
|
||||
late Future futureGroup;
|
||||
|
||||
List<ReactionData> _reactions = [];
|
||||
final Map<int, ReactionData?> _selectedReactions = {};
|
||||
final CountersHelper countersHelper = Get.find<CountersHelper>();
|
||||
@@ -147,12 +140,12 @@ class _PopularTabState extends State<PopularTab> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
futureGroup = Communitygetmethod().getPopularTagsdata(widget.id);
|
||||
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> _fetchIcons() async {
|
||||
_fetchIcons() {
|
||||
_reactions = fetchlikeIconsModel!.data ?? [];
|
||||
for (var post in commonobjmodel!.data) {
|
||||
//Check if post as a like icon
|
||||
@@ -174,14 +167,9 @@ class _PopularTabState extends State<PopularTab> {
|
||||
}
|
||||
|
||||
Future<void> setValues() async {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_setModel();
|
||||
countersHelper.setListsPopular();
|
||||
_fetchIcons();
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
setState(() {});
|
||||
});
|
||||
});
|
||||
_setModel();
|
||||
countersHelper.setListsPopular();
|
||||
_fetchIcons();
|
||||
}
|
||||
|
||||
_sortTags(index) {
|
||||
@@ -252,10 +240,15 @@ class _PopularTabState extends State<PopularTab> {
|
||||
.toList());
|
||||
}
|
||||
|
||||
Future<void> _initialize() async {
|
||||
await Communitygetmethod().getPopularTagsdata(widget.id);
|
||||
await setValues();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: futureGroup,
|
||||
future: _initialize(),
|
||||
builder: (ctx, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: ShimmerCommon());
|
||||
@@ -270,9 +263,8 @@ class _PopularTabState extends State<PopularTab> {
|
||||
);
|
||||
}
|
||||
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
setValues();
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
|
||||
return Stack(clipBehavior: Clip.none, children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
@@ -357,16 +349,15 @@ class _PopularTabState extends State<PopularTab> {
|
||||
}
|
||||
|
||||
class LatestTab extends StatefulWidget {
|
||||
LatestTab({super.key, required this.id});
|
||||
const LatestTab({super.key, required this.id});
|
||||
|
||||
int id;
|
||||
final int id;
|
||||
|
||||
@override
|
||||
State<LatestTab> createState() => _LatestTabState();
|
||||
}
|
||||
|
||||
class _LatestTabState extends State<LatestTab> {
|
||||
late Future latestfuture;
|
||||
List<ReactionData> _reactions = [];
|
||||
final Map<int, ReactionData?> _selectedReactions = {};
|
||||
final CountersHelper countersHelper = Get.find<CountersHelper>();
|
||||
@@ -374,9 +365,6 @@ class _LatestTabState extends State<LatestTab> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// tagdetailobj
|
||||
latestfuture = Communitygetmethod().getTagsdata(widget.id);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -402,15 +390,9 @@ class _LatestTabState extends State<LatestTab> {
|
||||
}
|
||||
|
||||
Future<void> setValues() async {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_setModel();
|
||||
countersHelper.setListsPopular();
|
||||
_fetchIcons();
|
||||
});
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
setState(() {});
|
||||
});
|
||||
_setModel();
|
||||
countersHelper.setListsPopular();
|
||||
_fetchIcons();
|
||||
}
|
||||
|
||||
_sortTags(index) {
|
||||
@@ -481,10 +463,15 @@ class _LatestTabState extends State<LatestTab> {
|
||||
.toList());
|
||||
}
|
||||
|
||||
Future<void> _initialize() async {
|
||||
await Communitygetmethod().getTagsdata(widget.id);
|
||||
await setValues();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: latestfuture,
|
||||
future: _initialize(),
|
||||
builder: (ctx, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: ShimmerCommon());
|
||||
@@ -499,9 +486,7 @@ class _LatestTabState extends State<LatestTab> {
|
||||
);
|
||||
}
|
||||
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
setValues();
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return Stack(clipBehavior: Clip.none, children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
|
||||
@@ -111,8 +111,9 @@ class _CommunityDetailsState extends State<CommunityDetails> {
|
||||
color: const Color(0xFF222935),
|
||||
tooltip: "",
|
||||
itemBuilder: (BuildContext context) {
|
||||
bool isMember =
|
||||
comdetailobj?.data?.userLinkInCommunity?.userTypeXid?.name == "Member";
|
||||
bool isMember = comdetailobj
|
||||
?.data?.userLinkInCommunity?.userTypeXid?.name ==
|
||||
"Member";
|
||||
// => <PopupMenuEntry>
|
||||
return <PopupMenuEntry<Object>>[
|
||||
PopupMenuItem(
|
||||
@@ -748,7 +749,6 @@ class PostsTab extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PostsTabState extends State<PostsTab> {
|
||||
late Future postDetailfuture;
|
||||
List<ReactionData> _reactions = [];
|
||||
final Map<int, ReactionData?> _selectedReactions = {};
|
||||
final CountersHelper countersHelper = Get.find<CountersHelper>();
|
||||
@@ -757,7 +757,6 @@ class _PostsTabState extends State<PostsTab> {
|
||||
@override
|
||||
void initState() {
|
||||
CommunityId = Get.arguments["CommunityID"];
|
||||
postDetailfuture = CommunityDetail().getComPostApi(CommunityId);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
@@ -783,14 +782,9 @@ class _PostsTabState extends State<PostsTab> {
|
||||
}
|
||||
|
||||
Future<void> setValues() async {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_setModel();
|
||||
countersHelper.setListsPopular();
|
||||
_fetchIcons();
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
setState(() {});
|
||||
});
|
||||
});
|
||||
_setModel();
|
||||
countersHelper.setListsPopular();
|
||||
_fetchIcons();
|
||||
}
|
||||
|
||||
_sortTags(index) {
|
||||
@@ -861,10 +855,15 @@ class _PostsTabState extends State<PostsTab> {
|
||||
.toList());
|
||||
}
|
||||
|
||||
Future<void> _initialize() async {
|
||||
await CommunityDetail().getComPostApi(CommunityId);
|
||||
await setValues();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: postDetailfuture,
|
||||
future: _initialize(),
|
||||
builder: (ctx, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(
|
||||
@@ -883,9 +882,7 @@ class _PostsTabState extends State<PostsTab> {
|
||||
);
|
||||
}
|
||||
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
setValues();
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return Stack(clipBehavior: Clip.none, children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
|
||||
Reference in New Issue
Block a user