【问题标题】:How to format numbers as currency strings in Flutter如何在 Flutter 中将数字格式化为货币字符串
【发布时间】:2021-12-14 18:23:22
【问题描述】:

***大家好,如何将下面的代码转换为货币 Dart/Flutter?

flutter中有一个名为number format的类,但我不太明白。你能帮忙解决这个问题吗? 示例“$ 3,500.00”***

----

 @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Text(
          "Toplam Masraf: ",
          style: TextStyle(
              color: Colors.orange.shade500,
              fontSize: 15,
              fontWeight: FontWeight.w600),
        ),
        Text(
          
            toplam >= 0 ? "${toplam.toStringAsFixed(2)}" : "0.00".toString(),
          
          style: TextStyle(
              color: Colors.orange.shade900,
              fontSize: 20,
              fontWeight: FontWeight.w800),
    ),
        Text(
          "₺",
          style: TextStyle(
              color: Colors.orange.shade900,
              fontSize: 25,
              fontWeight: FontWeight.w800),
        )
      ],
    );
  }

【问题讨论】:

标签: flutter dart formatting currency


【解决方案1】:

也许NumberFormat 课程会帮助你:https://api.flutter.dev/flutter/intl/NumberFormat-class.html

你试过这些例子吗?

【讨论】:

    猜你喜欢
    • 2012-03-08
    • 1970-01-01
    • 2011-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多