hello guys as a beginner on flutter i'm having an issue with the dropdownbutton widget as shown on the joined GIF
on the backend everything seems to work normally every row n the list has it Answer properly but on the screen the values changes for the whole screen not row by row that's the source code for the ChangeNotifier() :
class ChoiceHandler extends ChangeNotifier {
final List<String> _dropdownElements = ['Not Done', 'Partially Done', 'Done'];
List<String> get dropdownElement => _dropdownElements;
late String _selectedItemValue;
String get selected => _selectedItemValue;
selectedValues(String s) {
_selectedItemValue = s;
notifyListeners();
}
}
and under listView here is the code for the dropdownButton :
Expanded(
child: ListView.builder(
itemCount: propositions.length,
itemExtent: 50.0,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(propositions[index]),
trailing: Consumer<ChoiceHandler>(
builder: (_, provider, __) {
return DropdownButton<String>(
value: dropdownValue,
onChanged: (newValue) {
provider.selectedValues(newValue as String);
dropdownValue = newValue;
print((propositions[index]) + " " + newValue); // here i can the results when i'm changing values
},
items: provider.dropdownElement
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
);
},
) //_dropdown(index),
);
thanks in advance
i've found the issue i've misplaced the declaration of a veriable ,th variable "dropdownValue" was declared above as a global variable , and then i've changed it place to where it's shown on the source code :