搜索插件、代码仓与 APP 分类

number_pad_keyboard 封面
插件详情v0.0.6

number_pad_keyboard

一个 Flutter 包,提供可自定义的数字键盘,用于输入 PIN 码或数字输入。它包含数字和按钮的自定义样式等功能。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
52
喜欢数
90
Pub 分数
160

安装插件

flutter pub add number_pad_keyboard

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,提供可自定义的数字键盘,专为输入 PIN 码或数字输入而设计。它允许开发者通过自定义样式来调整数字和按钮的外观,确保跨平台的一致性。该键盘针对移动和桌面环境进行了优化,支持 Android、iOS、Web、macOS、Windows 和 Linux。适用于身份验证流程、支付输入或任何需要安全数字输入的场景。

适合场景

  • PIN码输入
  • 安全的数字输入
  • 支付表单字段
  • 认证屏幕
  • 用户ID验证
  • 数字键盘接口

主要特点

  • 可自定义的按钮样式
  • 跨平台兼容性
  • PIN 码聚焦设计
  • 可配置的数字布局
  • 响应式 UI 组件
  • 与 TextFormField 的轻松集成

适合对象

  • 移动应用开发人员
  • Web 应用程序创建者
  • 桌面应用程序构建工具
  • 注重安全的应用程序
  • 需要数值输入的表单

使用建议

  • 仅限数字输入
  • 无内置验证
  • 需要手动处理输入事件
  • 不适合用于文本输入
  • 可能需要额外的样式以支持深色模式

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Number Pad Keyboard

A Flutter package that provides a customizable number pad keyboard widget for entering PIN codes or numeric input.

Features

  • Customizable Design: Easily customize the look and feel of the number pad keyboard.
  • PIN Code Entry: Suitable for entering PIN codes or any numeric input in Flutter applications.
  • Flexible Usage: Integrate seamlessly into any Flutter project requiring a numeric keyboard interface.

Installation

Add the following dependency to your pubspec.yaml file:

dependencies:
  number_pad_keyboard: ^1.0.0

Importing

To use the Number Pad Keyboard widget in your Flutter project, import it as follows:

import 'package:number_pad_keyboard/number_pad_keyboard.dart';

Example


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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Number Pad Keyboard Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final TextEditingController _textController = TextEditingController();

  void _addDigit(int digit) {
    if (_textController.text.length < 10) {
      setState(() {
        _textController.text = _textController.text + digit.toString();
      });
    }
  }

  void _backspace() {
    if (_textController.text.isNotEmpty) {
      setState(() {
        _textController.text =
            _textController.text.substring(0, _textController.text.length - 1);
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Number Pad Keyboard Example'),
      ),
      body: SizedBox(
        width: double.infinity,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(20.0),
              child: TextFormField(
                controller: _textController,
                decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: 'PIN Code',
                ),
                readOnly: true,
                textAlign: TextAlign.center,
                style: const TextStyle(fontSize: 24.0),
              ),
            ),

            const SizedBox(height: 200.0,),

            NumberPadKeyboard(
              addDigit: _addDigit,
              backspace: _backspace,
              enterButtonText: 'ENTER',
              onEnter: () {
                debugPrint('PIN Code: ${_textController.text}');
              },
            ),
          ],
        ),
      ),
    );
  }
}

所属分类

源码仓库

使用此插件的项目

暂无相关数据。