패키지, 저장소 및 앱 카테고리 검색

masked_text_field 표지
패키지 상세v1.0.2

masked_text_field

텍스트를 포맷하기 위한 마스크 텍스트 필드용 패키지입니다. 전화번호, IP 주소 또는 기타 형식에 대한 마스크가 필요하시면 이 패키지를 사용하세요.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
656
좋아요
29
Pub 점수
150

패키지 설치

flutter pub add masked_text_field

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

전화번호, IP 주소 또는 기타 구조화된 데이터와 같은 필드에 적합한 사용자 정의 마스크를 지원하는 포맷팅 텍스트 입력을 가능하게 하는 플러터 패키지입니다. 사용자가 입력할 때 자동으로 포맷팅을 적용하여 일관된 입력 패턴을 보장합니다. 실시간 검증을 지원하며, Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼과 호환됩니다. 강제 형식을 통해 사용자 오류를 줄이고 폼 처리를 간편하게 만듭니다.

사용 사례

  • 전화번호 입력
  • IP 주소 입력
  • 신용 카드 번호 형식화
  • 날짜 및 시간 필드 마스킹
  • 사용자 정의 형식 입력
  • 양식 검증 지원

주요 기능

  • 실시간 마스크 적용
  • 사용자 정의 마스크 패턴
  • 크로스 플랫폼 지원
  • 자동 커서 위치 지정
  • 내장 검증
  • TextFormField과의 간편한 통합

적합한 대상

  • 엄격한 형식을 요구하는 폼 입력
  • 데이터 입력 폼이 있는 모바일 및 웹 애플리케이션
  • 재사용 가능한 입력 마스크가 필요한 개발자
  • 국제 번호 형식을 지원하는 앱
  • UX 중심의 입력 경험

고려 사항

  • 신중한 마스크 패턴 설계가 필요할 수 있습니다
  • 텍스트 기반 입력에 제한됨
  • 복잡한 마스크와 관련된 성능 영향 가능성
  • 텍스트가 아닌 입력 유형에는 적합하지 않습니다
  • 포커스 및 선택을 수동으로 처리해야 합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Masked Text Field

Masked Text Field

pub package pub points LinkedIn Instagram Facebook Youtube

Features

A package for masked text field for format your text (eg. Date, phone number, IP address etc.), so if you want a mask for phone number, or IP address or any kind of format. Use this package.
Image

Getting started

Add the dependency in pubsec.yaml file.

dart
  dependencies:
    flutter:
      sdk: flutter
    masked_text_field: any

Usage Example

import flutter_social_button.dart


import 'package:masked_text_field/masked_text_field.dart';

for add Text Field

It's very simple, it's a Widget as all the other ones.


MaskedTextField
(
    maskedTextFieldController: textfieldController,
    mask: "xxx.xxx.xxx.xxx",
    maxLength: 15,
    keyboardType: TextInputType.number,
    inputDecoration: new InputDecoration(
    hintText: "192.192.192.192", 
    counterText: "",
    labelText: "IP Address"),
);

'x' is the normal char that your text will have.

this sample reproduces something like this in the end: 192.192.192.192.

You can also change the escape character you want to use.

If you want to change it, you just need to fill the property escapeCharacter with the character you want.


MaskedTextField
(
    maskedTextFieldController: textfieldController,
    escapeCharacter: '#',
    mask: "###.###.###.###",
    maxLength: 15,
    keyboardType: TextInputType.number,
    inputDecoration: new InputDecoration(
    counterText: "",
    hintText: "192.192.192.192", 
    labelText: "IP Address"),
);

'x' is the default escape character.

Example


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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomePage(title: 'Masked Text Field'),
    );
  }
}

class HomePage extends StatefulWidget {
  final String title;
  const HomePage({Key? key, required this.title}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {

  var ipController = TextEditingController();
  var dateController = TextEditingController();
  var phoneController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const Text('Enter IP Address'),
            const SizedBox(height: 5,),
            MaskedTextField(
              textFieldController: ipController,
              inputDecoration: const InputDecoration(
                hintText: '192.192.192.192',
                  counterText: ""
              ),
              autofocus: true,
              mask: 'xxx.xxx.xxx.xxx',
              maxLength: 15,
              keyboardType: TextInputType.number,
              onChange: (String value) {
                print(value);
              },
            ),
            const SizedBox(height: 10,),
            const Text('Enter Date'),
            const SizedBox(height: 5,),
            MaskedTextField(
              textFieldController: dateController,
              inputDecoration: const InputDecoration(
                  hintText: 'DD/MM/YYYY',
                  counterText: ""
              ),
              autofocus: true,
              mask: 'xx/xx/xxxx',
              maxLength: 10,
              keyboardType: TextInputType.number,
              onChange: (String value) {
                print(value);
              },
            ),
            const SizedBox(height: 10,),
            const Text('Enter Phone Number'),
            const SizedBox(height: 5,),
            MaskedTextField(
              textFieldController: phoneController,
              inputDecoration: const InputDecoration(
                  hintText: '98765-43210',
                  counterText: "",
                prefixText: '+91 ',
              ),
              autofocus: true,
              mask: 'xxxxx-xxxxx',
              maxLength: 11,
              keyboardType: TextInputType.number,
              onChange: (String value) {
                print(value);
              },
            ),
          ],
        ),
      ),
    );
  }
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.