-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
103 lines (98 loc) · 3.66 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import 'package:flutter/material.dart';
import 'package:flutterotpfield/flutterotpfield.dart';
void main() {
runApp(const OtpScreen());
}
class OtpScreen extends StatefulWidget {
const OtpScreen({Key? key}) : super(key: key);
@override
State<OtpScreen> createState() => _OtpScreenState();
}
class _OtpScreenState extends State<OtpScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 50,),
// with default design
FlutterOtpField(
inputFieldLength: 6,
spaceBetweenFields: 10,
onValueChange: (String value) {
print("otp changed $value");
},
onCompleted: (String value) {
print("otp $value");
},),
const SizedBox(height: 50,),
// with custom input field design
Center(child: FlutterOtpField(
inputFieldLength: 6,
spaceBetweenFields: 10,
inputDecoration: InputDecoration(
constraints: const BoxConstraints(maxHeight: 46),
fillColor: Colors.transparent,
filled: true,
hintText: "0",
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(8)),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xff969696),
width: 1.0),
borderRadius:
BorderRadius.circular(8))),
onValueChange: (String value) {
print("otp changed $value");
},
onCompleted: (String value) {
print("otp $value");
},)),
const SizedBox(height: 30,),
Center(child: 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");
},)),
],
)
);
}
}