Flutter Textfield 捕获美元金额并申请费用
我们有一个 flutter 文本字段,用户可以输入一个 int 形式的金额,我们想要做的是 int 计算出减去费用的金额。可能是我无法弄清楚我做错了什么
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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
Try this:
试试这个
或这个
如果您需要以下代码,也可以尝试这个
Try this
or this
You can also try this if you need below code