Issue
We have a flutter text field whereby a user can enter an amount as an int, and what we want to do is that int calculated an amount less a fee. Probably is I cannot work out here what I am doing wrong
TextFormField(
controller: _offerAmountController,
textInputAction: TextInputAction.next,
decoration: const InputDecoration(
hintText: '5-9999',
prefixIcon: Icon(Icons.attach_money_rounded),
// labelText: 'Your Offer',
),
keyboardType: TextInputType.number,
onChanged: (offerAmount) {
double sum = int.parse(offerAmount) * 0.1;
_offer = sum as int;
}),
Text(formatCurrency.format(_offer),
style: Theme.of(context)
.textTheme
.headlineSmall
.copyWith(color: Colors.blue[700]))
final formatCurrency =
NumberFormat.simpleCurrency(locale: 'en_AU', decimalDigits: 0);
Solution
Try this:
setState(() {
_offer = sum.toInt();
});
Answered By - Ante Bule
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.