When I change the "Ulke" value from the AsyncSelectInputForm, I call the notifyListeners() method so that the "Il" value is null.
When I do this, the value I entered in the "Adres Başlığı" TextInputForm returns to its initial value.
My widget:
@override
Widget build(BuildContext context) {
var cariAdres = Provider.of<CariAdresProvider>(context);
return Column(
children: [
TextInputForm(
initialValue: cariAdres.cariAdres?.adresBasligi,
label: "Adres Başlığı",
onChanged: (value) {
cariAdres.cariAdresTemp =
cariAdres.cariAdresTemp?.copyWith(
adresBasligi: value,
);
},
),
//todo ulke select
AsyncSelectInputForm(
pageTitle: "Ülke Seç",
label: "Ülke",
initialLabel: cariAdres.cariAdresTemp?.ulkeIdStr,
labelSetter: (item) {
return item.ulkeStr;
},
onChanged: (value, item, context) {
cariAdres.cariAdresTemp =
cariAdres.cariAdresTemp?.copyWith(
ulkeId: value,
ulkeIdStr: item.ulkeStr,
ilId: null,
ilIdStr: null,
);
cariAdres.notifyListeners();
},
fetchPage: //...,
),
//todo il select
AsyncSelectInputForm(
initialValue: cariAdres.cariAdresTemp?.ilId,
//... same code
)
//....
CodePudding user response:
It can be related a lot of possibilities, so we can't be sure which one is correct. But you can try to add some debugPrint in your build method in this way, you can expand your understanding for the situation.
Also, it can be about some logic in your change notifier provider or it can be about your widget tree-state or it can be about your sub widgets.
CodePudding user response:
My problem was that I had set the initialValue of TextInputForm to value cariAdres.cariAdres?.adresBasligi
and valued cariAdres.cariAdresTemp?.ulkeIdStr
to AsyncSelectInputForm's initialLabel.
I was able to fix this problem by replacing the cariAdres.cariAdres?.adresBasligi
value with the cariAdres.cariAdresTemp?.adresBasligi
value. :)