how are you? I have a problem with my if condition. When I set the condition to different from zero it displays all the products to me, but when I set higher even though the condition is to check it does not show anything yet there are products with a timeleft> 0. No matter how much I modify the code, it doesn't show me anything. Need help
Padding roomProductCard(BuildContext context, String bidProductId, String name, String price,
List imageUrl, int datebid, int datetime) {
CountdownTimerController controller;
int date = DateTime.now().millisecondsSinceEpoch;
int timeleft;
timeleft = (datebid + datetime) - date;
int endTime = DateTime.now().millisecondsSinceEpoch + timeleft;
if(timeleft>0)
return Padding(
padding: const EdgeInsets.all(6.0),
child: GestureDetector(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => productBidPage(productId: bidProductId,)));
},
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
boxShadow: [
BoxShadow(
color: Colors.grey, offset: Offset(-2, -1), blurRadius: 5)
]),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(7.0),
child: Image.network(
"${imageUrl[0]}",
height: 500,
width: 450,
)),
],
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(' ${name} ',
style: TextStyle(
fontSize: 24.0, fontWeight: FontWeight.bold)),
Text('$price ',
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.red)),
],
),
),
CountdownTimer(
textStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
controller: controller,
onEnd: () {
print('end');
},
endTime: endTime,
),
],
),
),
),
);
this function is called in the stream builder
Column(
children: [
StreamBuilder<QuerySnapshot>(
stream: roomProduct.roomProductData.where('roomId', isEqualTo: widget.roomId)
.snapshots(),
builder:(context, snap){
if(!snap.hasData){
return Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(
Colors.blue),
));
}else
{
return ListView.builder(
shrinkWrap: true,
physics: ScrollPhysics(),
itemCount: snap.data.docs.length,
itemBuilder: (context, int index){
final item = snap.data.docs[index];
return roomProductCard(context, item.data()['id'],
item.data()['productName'],
item.data()['price'],
item.data()['pictures'],
item.data()['dateBid'],
item.data()['datetime']);
},
);
}
return Container();
}
)
],
)
Aucun commentaire:
Enregistrer un commentaire