搜尋套件、儲存庫與 APP 分類

GitHub 儲存庫IsaiasSantana/currency_textfield

currency_textfield

用於貨幣文字輸入的控制器。

currency_textfield 專案封面
星標
11
分支
7
最近推送(UTC)
2025年11月17日
專案狀態
已封存

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

currency_textfield

Build Status pub package

A Controller for currency text input

Demo

sample

Install

Follow this guide

Usage

Import the library

import 'package:currency_textfield/currency_textfield.dart';

Create the Controller

CurrencyTextFieldController controller = CurrencyTextFieldController()

Parameters and getters

Currency Symbol, Decimal and Thousand separator

It's possible to customize currencySymbol, decimalSymbol and thousandSymbol:

var controller = CurrencyTextFieldController(currencySymbol: "RR", decimalSymbol: ".", thousandSymbol: ",");
Get double value, get int value and get number in string format

To get the number value from controller, you can use both the doubleValue or the intValue properties:

//Double value:
final double val = controller.doubleValue;
//Int value:
final int val = controller.intValue;
//String number:
final int val = controller.textWithoutCurrencySymbol;
Initial value

You can initialize the controller using a int or a double, but not both at the same time. To make this, just use initDoubleValue or initIntValue:

final CurrencyTextFieldController controller2 = CurrencyTextFieldController(initDoubleValue: 10);
final CurrencyTextFieldController controller3 = CurrencyTextFieldController(initIntValue: 1000);

// this will raise an error!
final CurrencyTextFieldController controller4 = CurrencyTextFieldController(initIntValue: 1000,initDoubleValue: 10);
Position of the symbol and separator

You can decide if the symbol will be before or after the number. To make this, just use currencyOnLeft:

// default with the currency before the number
final CurrencyTextFieldController controller = CurrencyTextFieldController();

// currency after the number
final CurrencyTextFieldController controller2 = CurrencyTextFieldController(currencyOnLeft: false);

And also define the separator between the symbol and the value with currencySeparator:

// the default value is a single space
final CurrencyTextFieldController controller = CurrencyTextFieldController(currencySeparator: ' -> ');
Block the user from setting negative numbers

Just set enableNegative to false

Force a value from outside the TextField
final CurrencyTextFieldController controller = CurrencyTextFieldController();
// using a double
controller.forceValue(initDoubleValue: 300.5);

// using an int
controller.forceValue(initIntValue: 10000);
Change the currency symbol of the controller
final CurrencyTextFieldController controller = CurrencyTextFieldController();
// keeping the current value:
controller.replaceCurrencySymbol('EUR');

// reseting the current value:
controller.replaceCurrencySymbol('EUR', resetValue: true);
Isaías Santana GitHub avatar
GitHub 作者

Isaías Santana ↗

Mobile Developer

InterSergipe, Brazil
語言DartHTMLSwiftKotlinObjective-C

此儲存庫發佈的套件

使用的依賴

依賴清單 3 項

  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}
  • flutter_lints開發依賴^6.0.0

如何選擇適合專案的儲存庫?

先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。

  1. 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
  2. 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
  3. 使用前在 GitHub 確認 README、授權條款與 Issues。

來源與維護

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗