Giter VIP home page Giter VIP logo

secure_numeric_keyboard's Introduction

Secure numeric keyboard to prevent KeyLogger attack and screen capture for web, app.

pub package

Screenshots

|

Forked Proejct from flutter_secure_keyboard

This project was forked and developed flutter_secure_keyboard.

Getting started

To use this plugin, add secure_numeric_keyboard as a dependency in your pubspec.yaml file. For example:

dependencies:
  secure_numeric_keyboard: ^2.2.2

Examples

class WithNumericSecureKeyboardExample extends StatefulWidget {
  @override
  _WithNumericSecureKeyboardExampleState createState() => _WithNumericSecureKeyboardExampleState();
}

class _WithNumericSecureKeyboardExampleState extends State<WithNumericSecureKeyboardExample> {
  final _secureKeyboardController = SecureKeyboardController();

  final _passwordEditor = TextEditingController();
  final _passwordTextFieldFocusNode = FocusNode();

  final _pinCodeEditor = TextEditingController();
  final _pinCodeTextFieldFocusNode = FocusNode();

  @override
  Widget build(BuildContext context) {
    // Set the WithNumericSecureKeyboard widget as the top-level widget
    // in the build function so that the secure keyboard works properly.
    return GestureDetector(
      onTap: () {
        _secureKeyboardController.hide();
        FocusScope.of(context).unfocus();
      },
      child: WithNumericSecureKeyboard(
        controller: _secureKeyboardController,
        child: Scaffold(
            appBar: AppBar(title: Text('with_numeric_secure_keyboard_example')),
            resizeToAvoidBottomInset: false,
            backgroundColor: Colors.white,
            body: _buildContentView()
        ),
      ),
    );
  }

  Widget _buildContentView() {
    // We recommend using the ListView widget to prevent widget overflow.
    return ListView(
      padding: const EdgeInsets.all(8.0),
      children: [
        SizedBox(height: 32.0),
        _buildPinCodeTextField(),
        SizedBox(height: 120.0),
        _buildPasswordTextField(),
      ],
    );
  }

  Widget _buildPasswordTextField() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        const Text('Password'),
        TextFormField(
          controller: _passwordEditor,
          focusNode: _passwordTextFieldFocusNode,
          // We recommended to set false to prevent the software keyboard from opening.
          enableInteractiveSelection: false,
          obscureText: true,
          autocorrect: false,
          enableSuggestions: false,
          onTap: () {

            _secureKeyboardController.show(
              focusNode: _passwordTextFieldFocusNode,
              initText: _passwordEditor.text,
              keyboardTheme: KeyboardTheme(
                showTopShadow: true,
              ),
              onCharCodesChanged: (List<int> charCodes) {
                _passwordEditor.text = String.fromCharCodes(charCodes);
              },
              // on
            );
          },
        ),
      ],
    );
  }

  Widget _buildPinCodeTextField() {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        const Text('PinCode'),
        TextFormField(
          controller: _pinCodeEditor,
          focusNode: _pinCodeTextFieldFocusNode,
          // We recommended to set false to prevent the software keyboard from opening.
          enableInteractiveSelection: false,
          // obscureText: true,

          autocorrect: false,
          enableSuggestions: false,
          onTap: () {
          },
        ),
      ],
    );
  }
}

Package

  • WithNumericSecureKeyboard - A widget that implements a secure keyboard with controller.
  • SecureKeyboardController - Controller to check or control the state of the secure keyboard.

Note: The parameters marked with an asterisk(*) are required.

WithNumericSecureKeyboard

Parameter Description
controller* Controller to control the secure keyboard.
child* A child widget with a secure keyboard.
stringKeyColor The color of the string key(alphanumeric, numeric..).
Default value is const Color(0xFF313131).
actionKeyColor The color of the action key(shift, backspace, clear..).
Default value is const Color(0xFF222222).
doneKeyColor The color of the done key.
Default value is const Color(0xFF1C7CDC).
activatedKeyColor The key color when the shift action key is activated. If the value is null, doneKeyColor is used.
keyTextStyle The text style of the text inside the keyboard key.
Default value is const TextStyle(color: Colors.white, fontSize: 17.0, fontWeight: FontWeight.w500).
screenCaptureDetectedAlertTitle Security Alert title, only works on iOS.
screenCaptureDetectedAlertMessage Security Alert message, only works on iOS
screenCaptureDetectedAlertActionTitle Security Alert actionTitle, only works on iOS.

SecureKeyboardController

Function Description
isShowing Whether the secure keyboard is showing.
show Show secure keyboard.
hide Hide secure keyboard.

SecureKeyboardController.show()

Parameter Description
type* The type of the secure keyboard.
focusNode The FocusNode that will receive focus on.
initText The initial value of the input text.
inputTextLengthSymbol The symbol to use when displaying the input text length.
obscuringCharacter The secure character to hide the input text.
Default value is .
maxLength The maximum length of text that can be entered.
alwaysCaps Whether to always display uppercase characters.
Default value is false.
obscureText Whether to hide input text as secure characters.
Default value is true.
shuffleNumericKey Whether to shuffle the position of the numeric keys.
Default value is true.
hideKeyInputMonitor Whether to hide the key input monitor.
Default value is false.
disableKeyBubble Whether to disable the key bubble.
Default value is false.
theme You can style the keyboard Theme
onKeyPressed Called when the key is pressed.
onCharCodesChanged Called when the character codes changed.

KeyboardTheme

Parameter Description
keypadHeight The height of the keyboard's content.
Default value is 270.0.
keyboardHeight The height of the keyboard.
Default value is 300.0.
keyRadius The radius of the keyboard key.
Default value is 4.0.
keySpacing The spacing between keyboard keys.
Default value is 1.2.
backgroundColor The background color of the keyboard.
Default value is Colors.white.
keyBackgroundColor The background color of the keypad.
Default value is Colors.white.
showTopShadow Set whether to show the upper gradient of the keyboard or not
Default value is false.
topShadowColor The color of the gradient at the top of the keyboard const Color(0xFFF5F5F5).

secure_numeric_keyboard's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.