Flutter Döngüsel İlerleme göstergesini nasıl gizleyebilirim veya reddedebilirim [çoğalt]
Dec 18 2020
API'den bazı verileri alıyorum, ihtiyacım olan şey, API yüklenene kadar yükleyiciyi göstermek. Sorun, yükleyici iyi çalışıyor ancak onu nasıl kapatabilirim bilmiyorum.
Benim kodum
Future<http.Response> _trySubmit3() async {
final isValid2 = _formKey3.currentState.validate();
FocusScope.of(context).unfocus();
if (isValid2) {
showDialog(
context: context,
builder: (BuildContext context) {
return Center(child: CircularProgressIndicator(
valueColor: new AlwaysStoppedAnimation<Color>(Color(0xff00abb5)),
),);
});
print(smsOTP.text);
print(userConfirmPassword.text);
var url = '123/set_password.php?email=${userEmail.text}&password=${userConfirmPassword.text}';
print(url);
http.Response res = await http.get(url,
headers: <String, String>{
'token': 'my token'
},
);
var data = json.decode(res.body.toString());
print(data);
print(data['status']);
if(data['status'].toString() == "success"){
// I need to close the loader here
}
}
Yanıtlar
UmaizKhan Dec 18 2020 at 19:02
Stackoverflow'a hoş geldiniz :)
Bu hile ile bunu yapabilirsiniz Navigator.pop (bağlam). Bence başarısını böyle yapabilirsen saklaman gerekiyor
if(data['status'].toString() == "success"){
Navigator.pop(context)
}
StefanoA. Dec 18 2020 at 19:00
Tüm işlemler tamamlandıktan hemen sonra, Dialog
içeren ifadeyi reddetmek CircularProgressIndicator
istiyorsanız, aşağıdaki kodu kullanabilirsiniz:
Navigator.pop(context);
Sizin örneğinizde uygulanan aşağıdaki gibi görünecektir:
Future<http.Response> _trySubmit3() async {
final isValid2 = _formKey3.currentState.validate();
FocusScope.of(context).unfocus();
if (isValid2) {
showDialog(
context: context,
builder: (BuildContext context) {
return Center(child: CircularProgressIndicator(
valueColor: new AlwaysStoppedAnimation<Color>(Color(0xff00abb5)),
),);
});
print(smsOTP.text);
print(userConfirmPassword.text);
var url = '123/set_password.php?email=${userEmail.text}&password=${userConfirmPassword.text}';
print(url);
http.Response res = await http.get(url,
headers: <String, String>{
'token': 'my token'
},
);
var data = json.decode(res.body.toString());
print(data);
print(data['status']);
if(data['status'].toString() == "success"){
Navigator.pop(context); // closing the Dialog with the CircularProgressIndicator
}
}
}
Gene Simmons, KISS Çizgi Romanlarının Potansiyel Olarak "İnsanlığı Yeniden Yaratabileceğini" Söyledi
Donovan, Şarkılarından 1'ini The Beatles'ın "Lucy in the Sky with Diamonds" şarkısıyla karşılaştırdı
Charly Reynolds Yakın Zamandaki Vokal Kord Ameliyatını Açıkladı: 'Şarkı Söylemekte Sorun Yaşıyordum'
Kevin Jonas'ın Kızı Alena, Doğum Günü Fotoğrafında Büyümüş Görünüyor: '9 Yaşında Gerçek Hissetmiyor'