Hello Friends Please help my Here i cant update my Listview.Builder When i click on my icons i got api new response but my listing is not updating please help me out ! what is the exact problem when i call my Flag ?? I can get response from my server i got listing ! what i need if data is print i need to change my listview.builder...if u have any idea plase help me
This is my api call
Future<AllPhotoListing> Photolist() async {
sharedPreferences = await SharedPreferences.getInstance();
Map data = {
"AccessToken": sharedPreferences.getString("AccessToken"),
"CustomerId": sharedPreferences.getInt("CustomerId"),
"CampaignId": sharedPreferences.getInt("PhotographerCampaignId"),
"Type" : widget.Type,
"FilterType": Flag
};
print(data);
final http.Response response = await http.post(
Constants.CUSTOMER_WEBSERVICE_URL + "/photoslist",
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(data),
);
debugPrint(response.body);
if (response.statusCode == 200) {
// If the server did return a 201 CREATED response,
// then parse the JSON.
print("Response status : ${response.statusCode}");
print("Response status : ${response.body}");
return AllPhotoListing.fromJson(json.decode(response.body));
} else {
// If the server did not return a 201 CREATED response,
// then throw an exception.
throw Exception('Failed to load data');
}
}
here is my body part
Scaffold(
appBar: getAppBar(),
body: Stack(
children: <Widget>[
(_futurePhotoList == null)
? Text("No data found. Please try again later.")
: FutureBuilder<AllPhotoListing>(
future: _futurePhotoList,
builder: (context, snapshot) {
if (snapshot.hasData) {
List<FolderList> items = snapshot.data.folderList;
int Like = snapshot.data.totalLikes;
int comment = snapshot.data.totalComments;
int share = snapshot.data.totalShared;
int album = snapshot.data.totalSelectedPhotosForAlbum;
int totalcount = snapshot.data.totalPhotos;
return Form(
key: _formKey,
child: Stack(
children: <Widget>[
Positioned(
top: 2,
left: 1,
right: 3,
child: Container(
height: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(4.0),
child: Text(widget.catogry,
style: TextStyle(
fontFamily: "Nunito",
fontSize: 15,
color: Colors.black,
)
),
),
Padding(
padding: const EdgeInsets.only(left: 1),
child: Text("($totalcount)"),
),
Padding(
padding: EdgeInsets.only(left: 80,top: 5,bottom: 5),
child: InkWell(
onTap: (){
setState(() {
Flag = "L";
Photolist();
print(Flag);
// I cant update my Listview.builder From here
});
},
child: Column(
children: <Widget>[
Icon(Icons.thumb_up,color: Color(0xfff58634)),
Text("$Like",
style: TextStyle(color: Colors.black45,),),
]
),
),
),
Padding(
padding: EdgeInsets.only(left: 20,top: 5,bottom: 5),
child: InkWell(
onTap: (){
setState(() {
Flag = "C";
Photolist();
// I cant update my Listview.builder From here
});
print(Flag);
},
child: Column(
children: <Widget>[
Icon(Icons.chat_bubble,color: Color(0xfff58634)),
Text("$comment",style: TextStyle(color: Colors.black45,),),
]
),
),
),
Padding(
padding: EdgeInsets.only(left: 20,top: 5,bottom: 5),
child: InkWell(
onTap: (){
setState(() {
Flag = "S";
Photolist();
// I cant update my Listview.builder From here
});
print(Flag);
},
child: Column(
children: <Widget>[
Icon(Icons.share,color: Color(0xfff58634)),
Text("$share",style: TextStyle(color: Colors.black45,),),
]
),
),
),
Padding(
padding: EdgeInsets.only(left: 20,top: 5,bottom: 5),
child: InkWell(
onTap: (){
setState(() {
Flag = "A";
_isLoading = true;
Photolist();
// I cant update my Listview.builder From here
});
},
child: Column(
children: <Widget>[
Icon(Icons.photo_album,color: Color(0xfff58634),),
Text("$album",style: TextStyle(color: Colors.black45,),),
]
),
),
)
],
)
),
),
Padding(
padding: const EdgeInsets.only(top: 55),
child: DraggableScrollbar.semicircle(
alwaysVisibleScrollThumb: true,
controller: myScrollController,
child: ListView.builder(
controller: myScrollController,
itemCount: items.length,
itemBuilder: (context,index){
List<PhotoList> listing = items[index].photoList;
int totalcount = items[index].totalCount;
return Container(
decoration: new BoxDecoration(color: Colors.white12),
child: ExpansionTile(
initiallyExpanded: true,
trailing: Icon(Icons.arrow_drop_down, color: Colors.red),
title: Row(
children: <Widget>[
Text(
"" + items[index].title,
style: new TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w400,
color: Colors.black),
),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Text(
"($totalcount)",
style: new TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.w400,
color: Colors.black45),
),
),
],
),
children: <Widget>[
Container(
decoration: new BoxDecoration(color: Color(0xFFFFFFFF)),
padding: EdgeInsets.all(2.0),
child: StaggeredGridView.countBuilder(
crossAxisCount: countValue,
shrinkWrap: true,
primary: false,
crossAxisSpacing: 4,
mainAxisSpacing: 4,
itemCount: listing.length,
itemBuilder: (context , int index)
{
if (_selectionMode) {
return GridTile(
header: GridTileBar(
trailing: Icon(
_selectedIndexList.contains(listing[index].photoId) ? Icons
.check_circle_outline : Icons
.radio_button_unchecked,
color: _selectedIndexList.contains(listing[index].photoId) ? Colors
.green : Colors.black,
),
),
child: GestureDetector(
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
),
child: Image.network(listing[index].photoThumbnailImagePath,
height: 50,
width: 100,
fit: BoxFit.cover,
),
),
onLongPress: () {
setState(() {
_changeSelection(enable: false, index: index,listing: listing);
});
},
onTap: () {
setState(() {
if (_selectedIndexList.contains(listing[index].photoId)) {
_selectedIndexList.remove(listing[index].photoId);
} else {
//_selectedIndexList.add(index);
_selectedIndexList.add(listing[index].photoId);
print(_selectedIndexList);
//_changeSelection(enable: false, index: list[index].photoId);
}
});
},
),
);
}
else
{
return GridTile(
child: InkResponse(
child: Image.network(listing[index].photoThumbnailImagePath,
height: 50,
width: 100,
fit: BoxFit.cover,
alignment: Alignment.center,
loadingBuilder:(BuildContext context, Widget child,ImageChunkEvent loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(
value: loadingProgress.expectedTotalBytes != null ?
loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes
: null,
),
);
},
),
onLongPress: () {
setState(() {
_changeSelection(enable: true, index: index,listing: listing);
});
},
onTap:(){
setState(() {
Navigator.push(context, PageTransition(type: PageTransitionType.fade,
child:CampaignSinglePhotos(
currentindex: index,
ImageId: listing,
images: listing,
),duration: Duration(milliseconds: 500)));
});
},
),
);
}
},
staggeredTileBuilder: (int index) => StaggeredTile.count(1, index.isEven ? liting : 1.3),
),
)
],
),
);
},
),
)
),
],
),
);
}
else {
return Center(child: CircularProgressIndicator()
);
}
},
),
Positioned(
right: 13,
bottom: 80,
child: Center(
child: InkWell(
onTap: (){
changeMode();
},
child: CircleAvatar(
child: Icon(Icons.crop_free,color: Colors.red,),
backgroundColor: Colors.white,
maxRadius: 22,
),
),
)
),
],
),
);
User contributions licensed under CC BY-SA 3.0