flutter_numpad_widget 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

flutter_numpad_widget #

A set of Flutter widgets providing numpad input functionality without the soft keyboard.

Getting Started #

In your Flutter project add the dependency:

dependencies:
    ...
    flutter_numpad_widget: 0.0.1

Usage Example #

Import flutter_numpad_widget

import 'package:flutter_numpad_widget/flutter_numpad_widget.dart'

Formatted Phone Input #

The simplest implementation involves creating a NumpadController and passing it to a Numpad and a NumpadText.

class ExampleNumpadWidget extends StatelessWidget {

//Instantiate a NumpadController
final _controller = NumpadController(format: NumpadFormat.PHONE);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[
          Padding(
            padding: const Edgeinsets.all(16),
            child:NumpadText(
              controller: _controller,
              style: TextStyle(fontSize: 40)
            )
          ),
          Expanded(
            child: Numpad(
              controller: _controller,
              buttonTextSize: 40
            )
          )
        ]
      )
    );
  }
}

This will display a Numpad with a masked TextField above it showing the phone number the user has typed in.

Other uses #

It is also possible to use the Numpad on its own, and respond to user input by attaching a listener to the NumpadController.

class NumpadOnlyExample extends StatelessWidget {
  final _controller = NumpadController();

  NumpadOnlyExample() {
    this._controller.addListener(_controllerListener);
  }

  void _controllerListener() {
    //Do things with the data in the controller.
  }

  @override
  Widget build() {
    return Numpad(controller: _controller);
  }
}

The NumpadController exposes a rawString, rawNumber, and formattedString.

Feature Overview #

  • Optional hint text
  • Styleable text field and Numpad buttons
  • Automatic formatting of phone numbers, currency, and masked PINs.

For more information, see the documentation.

[0.1.1] July 23, 2019

Cleaned up code and documentation.

[0.1.0] July 22, 2019

Initial release of flutter_numpad_widget includes:

  • Numpad input widget
  • NumpadText display widget
  • NumpadController control widget

example/README.md

example #

A simple example implementation of flutter_numpad_widget.

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Numpad Example',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: FormattedNumpadExample(),
    );
  }
}

class FormattedNumpadExample extends StatelessWidget {
  final NumpadController _numpadController =
      NumpadController(format: NumpadFormat.PHONE);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Numpad Example'),
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(16.0),
              child: NumpadText(
                style: TextStyle(fontSize: 40),
                controller: _numpadController,
              ),
            ),
            Expanded(
              child: Numpad(
                controller: _numpadController,
                buttonTextSize: 40,
              ),
            )
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_numpad_widget: ^0.1.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:flutter_numpad_widget/flutter_numpad_widget.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
40
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]
70
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/flutter_numpad_widget.dart.

Run flutter format to format lib/flutter_numpad_widget.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test