random_number_keypad 1.0.2
random_number_keypad: ^1.0.2 copied to clipboard
A customizable Flutter widget providing a secure numeric keypad with random key positions, PIN masking, customizable length, and callback on PIN entry completion.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:random_number_keypad/random_number_keypad.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Random Number Keypad Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const RandomPinExample(),
);
}
}
class RandomPinExample extends StatelessWidget {
const RandomPinExample({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.lightGreen,
appBar: AppBar(title: const Text('Random PIN Keyboard')),
body: Center(
child: RandomNumberKeypad(
inputFillColor: Colors.white,
inputTextStyle:
const TextStyle(color: Colors.red, fontWeight: FontWeight.bold),
doneButtonTextStyle: const TextStyle(color: Colors.deepOrange),
pinLength: 4,
inputShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
showInput: true,
buttonColor: Colors.red,
buttonTextStyle: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
),
onComplete: (pin) {
print('Entered PIN: $pin');
// Add PIN validation logic here.
},
),
),
);
}
}