Change in one Dynamically created listview of textfiled showing same change in textfield in flutter

I am learning flutter by creating a currency conversion App and this is also my first App with flutter.

I want to create dynamically listview of cards with two textfields where I can write currency value to get the current exchange rate of another currency and vice-versa. I am adding new currency card by pressing the floating button. My problem is that if I write in one textfield it shows in all textfields. it should be showing conversion in the same card so that I can have a separate card for different currency conversions, As shown in the picture below,

I have tried,

  • searching on the internet but I could not found the solution of my problem
  • adding keys but maybe I am using keys in a wrong way!
  • creating a separate class for only TextEditingControllers

homepage where I am adding card into the list when floating button pressed.
sYptn

class _HomePageState extends State {
List comparisionCard = [];
Currency currency = Currency();

bool floatingButtonPressed = false;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(…),
body: Column(
children: [
CategorySelector(),
Expanded(
child: floatingButtonPressed == false
? Container()
: FutureBuilder(
future: currency.loadCurrencies(),
builder: (context, currencyListSnap) {
if (currencyListSnap.connectionState ==
ConnectionState.none &&
currencyListSnap.hasData == null) {
return Container();
}
return ListView.builder(
itemCount: comparisionCard.length,
itemBuilder: (context, index) {
return comparisionCard[index];
},
);
},
),
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
floatingButtonPressed = true;
var currencyList = await currency.loadCurrencies();
setState(
() {
comparisionCard.add(
CurrenciesComparisonCard(
key: UniqueKey(), currency: currencyList.addedCurrencies),
);
},
);
},
backgroundColor: Color(0xFFBB86FC),
child: Icon(Icons.add),
),
);
}
}

In this class, I am creating Card for currency conversion,

class CurrenciesComparisonCard extends StatelessWidget {
const CurrenciesComparisonCard({
this.currency,
Key key,
}) : super(key: key);
final List currency;

@override
Widget build(BuildContext context) {
return Consumer(builder: (context, inputData, child) {
return Column(
children: [
Container(
height: 180,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20)),
elevation: 12.0,
color: Color(0xFF1B1B1B),
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
child: CircleAvatar(
radius: 25.0,
backgroundImage: AssetImage(currency[0].image),
),
),
Text(
currency[0].currency,
style: TextStyle(fontWeight: FontWeight.bold),
),
SizedBox(
height: 8.0,
),
Container(
height: 50,
child: TextField(
key: UniqueKey(),
controller: inputData.textFieldController,
onChanged: (value) =>
inputData.userInputCurrencyValue = value,
onTap: () =>
inputData.textFieldController.clear(),
onSubmitted: (String userInput) {
inputData.outputCurrencyValue;
},
),
),
],
),
),
),
Expanded(…),
Expanded(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
InkWell(
child: CircleAvatar(
radius: 25.0,
backgroundImage: AssetImage(currency[1].image),
),
),
Text(
currency[1].currency,
style: TextStyle(fontWeight: FontWeight.bold),
),
SizedBox(
height: 8.0,
),
Container(
height: 50,
child: TextField(
key: UniqueKey(),
controller: inputData.textFieldController2,
onChanged: (value) =>
inputData.userInputCurrencyValue = value,
onTap: () =>
inputData.textFieldController2.clear(),
onSubmitted: (String userInput) {
inputData.outputCurrencyValue;
},
),
),
],
),
),
),
],
),
),
)
],
);
});
}
}

user-input model with the notifier

class UserInput extends ChangeNotifier {
double _currencyInput;
double _currencyOutput;
double _currencyValueDifference = 85.0;

WebService currencyConv = WebService();

TextEditingController textFieldController = TextEditingController();
TextEditingController textFieldController2 = TextEditingController();

set userInputCurrencyValue(String userInput) {
_currencyInput = double.parse(userInput);
print(‘currencyInput = $_currencyInput’);
}

get outputCurrencyValue {
_currencyOutput = _currencyInput * _currencyValueDifference;
textFieldController2.text = _currencyOutput.toStringAsFixed(2);
}

}

Thank you very much in advanced.