100% Dart based and lightweight PIN input field widget for Flutter
This widget keeps whole width of parent widget and layouts textfields in a way to create PIN code input field look it accepts string of any length and calls the onSubmit method when all fields are filled.
Install the latest version from pub.
Property | Default |
---|---|
onSubmit | Function |
fieldsCount | 4 |
isTextObscure | false |
fontSize | 40.0 |
borderRadius | 5.0 |
keybaordType | number |
keyboardAction | next |
clearButtonIcon | Icons.backspace |
clearButtonEnabled | true |
clearButtonColor | 0xFF66BB6A |
autoFocus | true |
Import the package:
import 'package:flutter/material.dart';
import 'package:pinput/pin_put/pin_put.dart';
void main() => runApp(PinPutTest());
class PinPutTest extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primaryColor: Colors.green,
hintColor: Colors.green,
),
home: Scaffold(
body: Builder(
builder: (context) => Padding(
padding: const EdgeInsets.all(40.0),
child: Center(
child: PinPut(
fieldsCount: 4,
onSubmit: (String pin) => _showSnackBar(pin, context),
),
),
),
)));
}
void _showSnackBar(String pin, BuildContext context) {
final snackBar = SnackBar(
duration: Duration(seconds: 5),
content: Container(
height: 80.0,
child: Center(
child: Text(
'Pin Submitted. Value: $pin',
style: TextStyle(fontSize: 25.0),
),
)),
backgroundColor: Colors.greenAccent,
);
Scaffold.of(context).showSnackBar(snackBar);
}
}
-
Fork it
-
Create your feature branch (git checkout -b my-new-feature)
-
Commit your changes (git commit -am 'Add some feature')
-
Push to the branch (git push origin my-new-feature)
-
Create new Pull Request