パッケージ、リポジトリ、アプリカテゴリを検索

easy_mask のカバー
パッケージ詳細v2.0.1

easy_mask

TextField、TextFormField、文字列用の簡単で強力なマスク。複数のマスクをサポートし、通貨用の逆マスクとプレースホルダーがあります。ユーザーのカーソルを制御します。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
2.8万
いいね数
159
Pub ポイント
150

パッケージをインストール

flutter pub add easy_mask

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Easy Mask は、強力なマスク機能を備えた Flutter パッケージで、テキストフィールドや文字列の入力フォーマットを簡単にします。複数のマスク、通貨形式用の逆マスク、カスタマイズ可能なプレースホルダーをサポートしています。ユーザー入力中にカーソル位置を知的に管理し、スムーズな入力体験を実現します。電話番号、日付、金融価値など構造化された入力を必要とするフォームに最適で、ユーザーが入力する際に自動的にフォーマットを適用することで使いやすさを向上させます。

用途

  • 構造化データを備えたフォーム入力
  • 通貨および数値のフォーマット
  • 日付および電話番号のマスク
  • リアルタイム入力検証
  • 動的マスク切り替え
  • プレースホルダの管理

主な機能

  • マルチマスク対応
  • 通貨用の逆マスク
  • 自動カーソル制御
  • カスタマイズ可能なプレースホルダー
  • リアルタイム形式
  • クロスプラットフォーム互換性

適している対象

  • フォーム中心のアプリを開発する開発者
  • フォーマットされた入力フィールドが必要なアプリ
  • 金融またはデータ入力アプリケーション
  • 一貫した入力パターンを必要とするプロジェクト
  • テキスト入力におけるUXを重視するチーム

注意事項

  • 複雑なマスクロジックの処理には注意が必要になる場合があります
  • 基本的な例以外のドキュメントは限られている
  • 多数の有効なマスクによるパフォーマンスへの潜在的影響
  • テキスト入力以外のシナリオには適していない
  • すべてのターゲットプラットフォームでテストが必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Easy Mask

Easy way to apply a mask to Flutter's TextFields and on Strings

To use it, you only need to pass EasyMask on TextField's parameter inputFormatters.

The Easy Mask cares about user's cursor position, to make fluid it's usability.

Supports Multi Mask based on masks length.

Supports Placeholders.

Sample

Usage

Simplest Sample

Import package:easy_mask/text_input_mask.dart

Then instantiate TextInputMask passing at least a String mask parameter.

import package:easy_mask/text_input_mask.dart
...
  TextField(
    inputFormatters: [ TextInputMask(mask: '99? (99) 999 99-99') ],
  ),
  TextField(
    inputFormatters: [ TextInputMask(mask: '999.999.999-99', reverse:true ) ],
  )
...

Formatting a String

import package:easy_mask/text_input_mask.dart
...
  String text = '432516565';
  MagicMask mask = MagicMask.buildMask('\\+99 (99) 99999-9999');
  String formattedString = mask.getMaskedString(text);
...
Multi Mask Sample

Import package:easy_mask/text_input_mask.dart

Then instantiate TextInputMask passing at least a String mask parameter.

import package:easy_mask/text_input_mask.dart
...
  TextField(
    inputFormatters: [ TextInputMask(mask: ['999.999.999-99', '99.999.999/9999-99'] ],
  ),
  TextField(
    inputFormatters: [ TextInputMask(mask: ['(99) 9999 9999', '(99) 99999 9999'], reverse:true ) ],
  )
...
PlaceHolder Sample

Import package:easy_mask/text_input_mask.dart

Then instantiate TextInputMask passing at least a String mask parameter.

import package:easy_mask/text_input_mask.dart
...
  TextField(
    inputFormatters: [ TextInputMask(mask: '999.999.999-99', placeholder: '_', maxPlaceHolders: 11 ],
  ),
...
Pretty Currency Sample

Import package:easy_mask/text_input_mask.dart

Then instantiate TextInputMask passing at least a String mask parameter.

import package:easy_mask/text_input_mask.dart
...
  TextField(
    inputFormatters: [ TextInputMask(mask: '\$! !9+,999.99', placeholder: '0', maxPlaceHolders: 3, reverse: true],
  ),
...
Possible parameters
  • mask can be a String or an List with the wanted masks pattern.
  • reverse is a boolean that indicates if the user will type from right to left. Used normally on currency TextFields.
  • maxLength is an Integer that limits the maximum size of returned masked text.
  • placeholder is a String character to be used as placeholder on untyped characters. Must define maxPlaceHolders
  • maxPlaceHolders an integer to map how many possible places it would be placed. Typed characters consumes a position from this counter.
Mask Patterns Characters

9 - is used to allow a number from 0-9

A - is used to allow a letter from a-z or A-Z

N - is used to allow a number or letter from 0-9, a-z or A-Z

X - is used to allow any character

Those tokens 9,A,N and X can be followed by one following modifier

? - indicates that is optional

+ - indicates that must have at least 1 or more repetitions

* - indicates that can have 0 or more repetitions

\ - is used as scape

*Any character that is interpreted as letter to be placed, can be followed by modifier **

! - Used to force print it, when it has at least 1 character typed on TextField.

Any other letters will be displayed on masking.

Examples of String masks

(card number) 999 999 999 999

(us cellphone) \+1 (999) 999 99 99

(currency) $! !9+,999.99

(version) 99?9?.99?9?.99?9?

(RG brazilian document) 99.999.999-N

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。