monu_otp_field 1.0.0
monu_otp_field: ^1.0.0 copied to clipboard
A Flutter package providing a sleek OTP verification UI with customizable styling and user-friendly callbacks.
Monu Otp Text Field #
A Flutter package for creating an OTP (One-Time Password) input field with customization options. This package provides an easy-to-use widget for capturing OTP codes in your Flutter applications.
Output #
https://github.com/Hasib74/monu_otp_text_field/assets/45905451/e4e0cc37-fb6c-474a-8955-e197ec32b0fe
Installation #
Add the following to your pubspec.yaml file:
dependencies:
monu_otp_field:
git:
url: https://github.com/Hasib74/monu_otp_text_field.git
ref: dev
Then run: #
flutter pub get
Example #
import 'package:monu_otp_field/monu_otp_field.dart';
MonuOtpTextField(
numberOfFields: 6,
borderColor: Theme.of(context).colorScheme.primary,
showFieldAsBox: false,
filled: true,
cursorColor: Theme.of(context).colorScheme.primary,
handleControllers: (List<TextEditingController?>? controllers) {
// Do something with the controllers
// e.g., concatenate the OTP values
},
onCodeChanged: (String code) {
// Handle validation or checks here
print("The OTP current code is: $code");
},
onSubmit: (String verificationCode) async {
// Handle the submitted OTP
// e.g., make an API call and proceed to the next step
},
),
Widget Properties #
numberOfFields: Set the number of OTP input fields. borderColor: Customize the color of the input field border. showFieldAsBox: Choose to show the input field as a box (true) or as a dash (false). filled: Decide whether the input field should be filled. cursorColor: Set the color of the cursor. handleControllers: Use this callback to work with the list of TextEditingController instances. onCodeChanged: Implement this callback for when the OTP code changes. onSubmit: Define this callback for when all fields are filled, and the OTP is submitted.
Customization #
Feel free to personalize the appearance of the OTP input field using the available properties. You can modify the border, cursor, and other visual aspects to match your app's design.
MonuOtpTextField(
// ... other properties
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0),
borderSide: BorderSide(color: Colors.red), // Customize the border color
),
fillColor: Colors.blue, // Customize the fill color
filled: true,
),
),
License #
MIT License
Copyright (c) 2023 Hasib Akon
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.