Reputation: 69
How can i make otp page like this in flutter, kindly help me and share whole code for the specific photo thanks
Upvotes: 0
Views: 2715
Reputation: 101
Alternatively for otp fields you can use FlutterOtpField package where it provides inputDecoration
property. With inputDecoration you can set your own design to OTP textFields.
Example:
FlutterOtpField(
inputFieldLength: 4,
spaceBetweenFields: 10,
inputDecoration: InputDecoration(
constraints: const BoxConstraints(maxHeight: 46),
fillColor: Colors.transparent,
filled: true,
hintText: "#",
counterText: "",
hintStyle: const TextStyle(
color: Color(0xff656565),
fontSize: 14,
fontWeight: FontWeight.w500),
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xff969696),
width: 1.0),
borderRadius:
BorderRadius.circular(30)),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xff969696),
width: 1.0),
borderRadius:
BorderRadius.circular(30))),
onValueChange: (String value) {
print("otp changed $value");
},
onCompleted: (String value) {
print("otp $value");
},)
Upvotes: 0
Reputation: 333
Add Following Package in pubspec.yaml
otp_text_field:
git:
url: https://github.com/AkashMore7427/OTPTextField
Add the following import line in your dart file
import 'package:otp_text_field/otp_field.dart';
import 'package:otp_text_field/otp_field_style.dart';
import 'package:otp_text_field/style.dart';
Add the following code to your body
Column(children: [
// Image.network("Add Image Link"),
Text(
"Enter verification Code",
),
Text(
"Code sent to [email protected]",
),
OTPTextField(
length: 4,
width: MediaQuery.of(context).size.width,
fieldWidth: 50,
style: TextStyle(fontSize: 17),
textFieldAlignment: MainAxisAlignment.spaceAround,
onCompleted: (pin) {
print("Completed: " + pin);
},
otpFieldStyle: OtpFieldStyle(
borderColor: Colors.black,
)),
Text("Resend in 0:45"),
//Add Button Widget Here
]),
Upvotes: 1