Widget KesfetKuponListUI(String mackodu1,String mackodu2,String mackodu3,String mackodu4,
String macadi1,String macadi2,String macadi3,String macadi4,
String mactahmin1,String mactahmin2,String mactahmin3,String mactahmin4,
String macoran1,String macoran2,String macoran3,String macoran4,
int ikredi,String paylasan,String kuponid,String useryorum,
String pname,String pfoto,bool kuponkilit
) {
DatabaseReference ref =FirebaseDatabase.instance.reference().child("tumkuponlar").child(kuponid).child("acanlar");
ref.child(myuserid).once().then((DataSnapshot snapshot){
if(snapshot.value==myuserid){
print("var");
setState(() {
kuponkilit=true;
});
}else{
print("yok");
setState(() {
kuponkilit=false;
});
}
});
return Stack(
children: <Widget>[
Flex(
verticalDirection: VerticalDirection.down,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
direction: Axis.vertical,
children: <Widget>[
Container(
width: double.maxFinite,
margin: EdgeInsets.only(top: 0),
decoration: BoxDecoration(
color: acikgri,
borderRadius: BorderRadius.all(Radius.circular(30)),
),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text("$pname",style: TextStyle(fontFamily: "ExoBold")),
CircleAvatar(
backgroundColor: sari,
backgroundImage: NetworkImage("$pfoto"),
radius: 30,
),
Text("KREDİ: $ikredi",style: TextStyle(fontFamily: "ExoBold"),)
],
),
SizedBox(height: 15,),
Row(
children: <Widget>[
Expanded(child: Text("$useryorum",style: TextStyle(fontFamily: "ExoLight"),textAlign: TextAlign.center,))
],
),
SizedBox(height: 15,),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text("$mackodu1",style: TextStyle(fontFamily: "ExoBold"),),
Text("$macadi1",style: TextStyle(fontFamily: "ExoBold"),),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text("$mactahmin1",style: TextStyle(fontFamily: "ExoBold"),),
Text("$macoran1",style: TextStyle(fontFamily: "ExoBold"),),
],
),
SizedBox(height: 15,),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text("$mackodu2",style: TextStyle(fontFamily: "ExoBold"),),
Text("$macadi2",style: TextStyle(fontFamily: "ExoBold"),),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text("$mactahmin2",style: TextStyle(fontFamily: "ExoBold"),),
Text("$macoran2",style: TextStyle(fontFamily: "ExoBold"),),
],
),
SizedBox(height: 15,),
mackodu3=="null"? Text(""):Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text("$mackodu3",style: TextStyle(fontFamily: "ExoBold"),),
Text("$macadi3",style: TextStyle(fontFamily: "ExoBold"),),
],
),
mackodu3=="null"? Text(""):Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text("$mactahmin3",style: TextStyle(fontFamily: "ExoBold"),),
Text("$macoran3",style: TextStyle(fontFamily: "ExoBold"),),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
mackodu4=="null"?Text(""):Text("daha fazlası...",style: TextStyle(fontFamily: "ExoBold"),),
],
),
SizedBox(height: 10,),
Visibility(
child: Container(
child: Text("10 Kişi tarafından açıldı",style: TextStyle(fontFamily: "ExoLight",color: yesil),),
),
),
],
),
),
SizedBox(height: 30,),
],
),
Visibility(
visible: kuponkilit,
child: Padding(
padding: const EdgeInsets.all(40),
child: GestureDetector(
onTap: ()async{
var sonuc =kredi-ikredi;
if(sonuc.isNegative){
print("yeterl, bakiyeniz yok");
showDialog(
context: context,
builder: (BuildContext context){
return AlertDialog(
title: Text("Kredi Yetersiz!",style: TextStyle(color: Colors.red,fontFamily: "ExoRegular")),
content: Text("yeterli krediniz yok.\nlütfen markete gidin",style: TextStyle(fontFamily: "ExoLight")),
actions: <Widget>[
new FlatButton(
onPressed: (){
Navigator.pop(context);
},
child: Text("TAMAM"))
],
);
}
);
}else{
print(kuponkilit);
FirebaseUser user=await FirebaseAuth.instance.currentUser();
String userid =user.uid;
FirebaseDatabase.instance.reference().child("kullanıcılar").child(user.uid).update({"kredi":sonuc});
FirebaseDatabase.instance.reference().child("tumkuponlar").child(kuponid).child("acanlar").update({"$userid":"$userid"});
FirebaseDatabase.instance.reference().child("kuponlar").child(paylasan).child(kuponid).child("acanlar").update({"$userid":"$userid"});
FirebaseDatabase.instance.reference().child("bildirim").child(paylasan).push().update({"bildirim":"$name senin kuponunu $ikredi krediye açtı","foto":"$foto"});
setState(() {
kuponkilit=false;
});
print(kuponkilit);
getKredi();
}
},
child: Container(
margin: EdgeInsets.only(top: 10),
width: double.maxFinite,
height: 250,
decoration: BoxDecoration(
color: yesil,
borderRadius: BorderRadius.all(Radius.circular(25))
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Icon(Icons.https,color: Colors.white,),
Text("$ikredi KREDİYE KUPONU AÇ",style: TextStyle(color: Colors.white,fontFamily: "ExoBold"),)
],
),
Text("kuponu açmak için tıklayın",style: TextStyle(color: Colors.white,fontFamily: "ExoLight"),)
],
)
),
),
)
)
],
);
}
我已经准备了一个列表,但是我想根据状态将列表中的容器隐藏起来,setState可以工作,但它不是隐藏的。 我一直在交易 这个问题持续了数周。
我尝试了各种方式,但没有成功。
给可以帮助的朋友 预先感谢。
我在等待你的答案