moneytextformfield 0.3.5+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

MoneyTextFormField #

MoneyTextFormField is one of the flutter widget packages that can be used to input values in the form of currencies, by displaying the output format in realtime.

This widget uses the FlutterMoneyFormatter package as a basic engine that has a very powerful ability to format currencies.

latest version last commit License

Dependencies : #

intl


Install #

For complete steps in installing MoneyTextFormField you can see in the Installation Guide.

Usage #

The following is the simplest example of using MoneyTextFormField:

import 'package:moneytextformfield/moneytextformfield.dart';

  /// ... some lines of code ...
  MoneyTextFormField(
    settings: MoneyTextFormFieldSettings()
  )
  /// ... some lines of code ...

For those of you who have not yet understood how to implement the widget package, you can use the following code in the main.dart file on your Flutter project:

import 'package:flutter/material.dart';
import 'package:moneytextformfield/moneytextformfield.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  TextEditingController mycontroller = TextEditingController();

  @override
  void initState() {  
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('MoneyTextFormField Demo'),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () => print(mycontroller.text),
          child: Icon(Icons.save),
        ),
        body: Column(
          children: <Widget>[
            /// Begin of :> MoneyTextFormField
            MoneyTextFormField(
              settings: MoneyTextFormFieldSettings(
                controller: mycontroller
              )
            )
            /// End of :> MoneyTextFormField
          ]
        )
      )
    );
  }
}

From the above code it will look more or less like the following:

MoneyTextFormField

Figure 1: Using full format

By doing a little modification, you will get the following results:

MoneyTextFormField

Figure 2: Using compact format

Referring to the example code above, to retrieve the value inputted by the user, you can get it through the mycontroller.text as in the onPressed event in the FloatingActionButton widget.


Configurations #

For now, MoneyTextFormField only uses one property to configure the display of that object, the settings property that has a data type is an instance of MoneyTextFormFieldSettings.

MoneyTextFormFieldSettings #

NameData TypeDescription
controllerTextEditingControllerA controller for an editable text field.
validatorFormFieldValidator<String>An optional method that validates an input. Returns an error string to display if the input is invalid, or null otherwise.
inputFormattersList<TextInputFormatter>A TextInputFormatter can be optionally injected to provide as-you-type validation and formatting of the text being edited.
onChangedvoidAn optional method that register a closure to be called when the object changes.
moneyFormatSettingsMoneyFormatSettingsSee here
appearanceSettingsAppearanceSettingsSee here
enabledboolWhether the form is able to receive user input.

Tips:

No need to initialize the value in controller.text, because the value will be ignored. the controller property is only intended to capture the value inputted by the user.

Notes:

The value contained in controller.text is exactly the same as the one inputted by the user and has a String data type. If you want to get results in the same format, you can use the FlutterMoneyFormatter package which is also used by MoneyTextFormField.

See detailed information about FlutterMoneyFormatter.

AppearanceSettings #

NameData TypeDescription
labelTextStringText that describes the input field. Default value is 'Amount'
hintTextStringText that suggests what sort of input the field accepts.
iconWidgetAn icon to show before the input field and outside of the decoration's container.
labelStyleTextStyleThe style to use for the labelText when the label is above (i.e., vertically adjacent to) the input field.
inputStyleTextStyleThe style to use for the input field.
formattedStyleTextStyleThe style to use for the formatted output text.
errorStyleTextStyleThe style to use for the errorText
paddingEdgeInsetGeometryThe amount of space by which to inset the widget

MoneyFormatSettings #

NameData TypeDescription
amountdoubleDecimal value that will be used when initializing the widget. Default value is 0.00.
fractionDigitsintThe fraction digits that will be used on formatted output. Default value is 2.
currencySymbolStringThe symbol that will be used on formatted output. Default value is '$' (dollar sign).
thousandSeparatorStringThe character that will be used as thousand separator on formatted output. Default value is ',' (comma).
decimalSeparatorStringThe character that will be used as decimal separator on formatted output. Default value is '.' (dot).
symbolAndNumberSeparatorStringThe character that will be used as separator between symbol and number. Default value is ' ' (space).
displayFormatMoneyDisplayFormatSee here

MoneyDisplayFormat #

MoneyDisplayFormat is an enum object with values such as the following:

NameDescription
nonSymbolUsed to display currency values in full format and without a currency symbol.
symbolOnLeftUsed to display currency values in full format with currency symbols on the left.
symbolOnRightUsed to display currency values in full format with currency symbols on the right.
compactNonSymbolUsed to display currency values in a short format and without a currency symbol.
compactSymbolOnLeftUsed to display currency values in a short format with a currency symbol on the left.
compactSymbolOnRightUsed to display currency values in a short format with a currency symbol on the right.

Demo #

For more complete samples, you can grab it from the example directory.

Our Other Package #

See our other packages here.

Help Me #

If you find any issues, bugs, have questions, or want to request a new features you can do it here. You can also help me to improve features or fix some issues by forking this project via Github

Change Log #

Are you curious about the changes that occur in each version? See here for detailed informations.


License #

Copyright (c) 2019, Fadhly Permata <fadhly.permata@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the MoneyTextFormField project.

0.3.* #

  • 0.3.5+1 #

    CHANGES:

    • Update FlutterMoneyFormatter version 0.8.0
  • 0.3.5 #

    CHANGES:

    • Update FlutterMoneyFormatter version 0.7.3
  • 0.3.4 #

    CHANGES:

    • Update FlutterMoneyFormatter version 0.7.1
    • Update documentation.
  • 0.3.3 #

    CHANGES:

    • Update FlutterMoneyFormatter version 0.6.3

    FIX:

  • 0.3.2 #

    FIX:

    • Update MoneyDisplayFormat enum values.
    • Documentation update.
  • 0.3.1 #

    CHANGES:

    • Update FlutterMoneyFormatter dependecy.
    • Update license on each files.
    • Update source code to match new dependecy changes.

    FIX:

  • 0.3.0 #

    ADD:

    • Padding capability
    • License on each files.

    CHANGES:

    • License changed into BSD

0.2.* #

  • 0.2.3 #

    ADD:
    • Support negative value
  • 0.2.2 #

    FIX:

  • 0.2.1 #

    CHANGES:

    • Upgrading FlutterMoneyFormatter
    • method adjustment
    • documentation adjustment
  • 0.2.0 #

    ADD:

    • Disabled whitespace on input text.

    CHANGES:

    • Initial values on input text taken from FlutterMoneyFormatter.formattedNonSymbol

0.1.* #

  • 0.1.2 #

    FIX:
    • Not disposing controller when user assign it.
  • 0.1.1 #

    FIX:
    • .gitignore file
  • 0.1.0 #

    CHANGES:

    • From now on, properties in the MoneyTextFormFieldSettings instance will be segmented based on their respective criteria.
    • Provides default values for all configuration instances.
    • Remove the mandatory properties of each parameter contained in the MoneyTextFormFieldSettings instance, so that it can be initialized without any parameters.
    • Separating files for each instance.
    • Update documentation to match any changes that occur in the package.

    ADD:

    • icon feature.
    • hintText feature.
    • errorStyle feature.
    • validator feature.
    • inputFormatters feature.
    • onChanged feature.
    • enabled feature.

0.0.* #

  • 0.0.4 #

    FIX:

    • Fix invalid closing quote on documentations.
  • 0.0.3 #

    FIX:

    • Major fix for documentation error tags.
  • 0.0.2 #

    ADD:

    • Create documentation.

    CHANGES:

    • Add controller to constructor param of MoneyTextFormFieldSettings instance
  • 0.0.1 #

    • pre-release (not recomended to use this version)

example/README.md

MoneyTextFormField #

MoneyTextFormField is one of the flutter widget packages that can be used to input values in the form of currencies, by displaying the output format in realtime.

This widget uses the FlutterMoneyFormatter package as a basic engine that has a very powerful ability to format currencies.

latest version last commit License

Dependencies : #

intl


Install #

For complete steps in installing MoneyTextFormField you can see in the Installation Guide.

Usage #

The following is the simplest example of using MoneyTextFormField:

import 'package:moneytextformfield/moneytextformfield.dart';

  /// ... some lines of code ...
  MoneyTextFormField(
    settings: MoneyTextFormFieldSettings()
  )
  /// ... some lines of code ...

For those of you who have not yet understood how to implement the widget package, you can use the following code in the main.dart file on your Flutter project:

import 'package:flutter/material.dart';
import 'package:moneytextformfield/moneytextformfield.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  TextEditingController mycontroller = TextEditingController();

  @override
  void initState() {  
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('MoneyTextFormField Demo'),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () => print(mycontroller.text),
          child: Icon(Icons.save),
        ),
        body: Column(
          children: <Widget>[
            /// Begin of :> MoneyTextFormField
            MoneyTextFormField(
              settings: MoneyTextFormFieldSettings(
                controller: mycontroller
              )
            )
            /// End of :> MoneyTextFormField
          ]
        )
      )
    );
  }
}

From the above code it will look more or less like the following:

MoneyTextFormField

Figure 1: Using full format

By doing a little modification, you will get the following results:

MoneyTextFormField

Figure 2: Using compact format

Referring to the example code above, to retrieve the value inputted by the user, you can get it through the mycontroller.text as in the onPressed event in the FloatingActionButton widget.


Configurations #

For now, MoneyTextFormField only uses one property to configure the display of that object, the settings property that has a data type is an instance of MoneyTextFormFieldSettings.

MoneyTextFormFieldSettings #

NameData TypeDescription
controllerTextEditingControllerA controller for an editable text field.
validatorFormFieldValidator<String>An optional method that validates an input. Returns an error string to display if the input is invalid, or null otherwise.
inputFormattersList<TextInputFormatter>A TextInputFormatter can be optionally injected to provide as-you-type validation and formatting of the text being edited.
onChangedvoidAn optional method that register a closure to be called when the object changes.
moneyFormatSettingsMoneyFormatSettingsSee here
appearanceSettingsAppearanceSettingsSee here
enabledboolWhether the form is able to receive user input.

Tips:

No need to initialize the value in controller.text, because the value will be ignored. the controller property is only intended to capture the value inputted by the user.

Notes:

The value contained in controller.text is exactly the same as the one inputted by the user and has a String data type. If you want to get results in the same format, you can use the FlutterMoneyFormatter package which is also used by MoneyTextFormField.

See detailed information about FlutterMoneyFormatter.

AppearanceSettings #

NameData TypeDescription
labelTextStringText that describes the input field. Default value is 'Amount'
hintTextStringText that suggests what sort of input the field accepts.
iconWidgetAn icon to show before the input field and outside of the decoration's container.
labelStyleTextStyleThe style to use for the labelText when the label is above (i.e., vertically adjacent to) the input field.
inputStyleTextStyleThe style to use for the input field.
formattedStyleTextStyleThe style to use for the formatted output text.
errorStyleTextStyleThe style to use for the errorText
paddingEdgeInsetGeometryThe amount of space by which to inset the widget

MoneyFormatSettings #

NameData TypeDescription
amountdoubleDecimal value that will be used when initializing the widget. Default value is 0.00.
fractionDigitsintThe fraction digits that will be used on formatted output. Default value is 2.
currencySymbolStringThe symbol that will be used on formatted output. Default value is '$' (dollar sign).
thousandSeparatorStringThe character that will be used as thousand separator on formatted output. Default value is ',' (comma).
decimalSeparatorStringThe character that will be used as decimal separator on formatted output. Default value is '.' (dot).
symbolAndNumberSeparatorStringThe character that will be used as separator between symbol and number. Default value is ' ' (space).
displayFormatMoneyDisplayFormatSee here

MoneyDisplayFormat #

MoneyDisplayFormat is an enum object with values such as the following:

NameDescription
nonSymbolUsed to display currency values in full format and without a currency symbol.
symbolOnLeftUsed to display currency values in full format with currency symbols on the left.
symbolOnRightUsed to display currency values in full format with currency symbols on the right.
compactNonSymbolUsed to display currency values in a short format and without a currency symbol.
compactSymbolOnLeftUsed to display currency values in a short format with a currency symbol on the left.
compactSymbolOnRightUsed to display currency values in a short format with a currency symbol on the right.

Demo #

For more complete samples, you can grab it from the example directory.

Our Other Package #

See our other packages here.

Help Me #

If you find any issues, bugs, have questions, or want to request a new features you can do it here. You can also help me to improve features or fix some issues by forking this project via Github

Change Log #

Are you curious about the changes that occur in each version? See here for detailed informations.


License #

Copyright (c) 2019, Fadhly Permata <fadhly.permata@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the MoneyTextFormField project.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  moneytextformfield: ^0.3.5+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:moneytextformfield/moneytextformfield.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

We analyzed this package on Nov 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_money_formatter ^0.8.0 0.8.3
Transitive dependencies
collection 1.14.11 1.14.12
intl 0.15.8 0.16.0
meta 1.1.7 1.1.8
path 1.6.4
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8