Skip to content

Commit 67ae593

Browse files
committed
added readOnly and reorganized code
1 parent 9b44b61 commit 67ae593

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/src/pin_code_fields.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ class PinCodeTextField extends StatefulWidget {
55
/// The [BuildContext] of the application
66
final BuildContext appContext;
77

8-
/// Text gradient for Pincode
9-
final Gradient? textGradient;
10-
118
///Box Shadow for Pincode
129
final List<BoxShadow>? boxShadows;
1310

@@ -187,6 +184,12 @@ class PinCodeTextField extends StatefulWidget {
187184
/// const EdgeInsets.all(20),
188185
final EdgeInsets scrollPadding;
189186

187+
/// Text gradient for Pincode
188+
final Gradient? textGradient;
189+
190+
/// Makes the pin cells readOnly
191+
final bool readOnly;
192+
190193
PinCodeTextField({
191194
Key? key,
192195
required this.appContext,
@@ -239,6 +242,7 @@ class PinCodeTextField extends StatefulWidget {
239242
this.hintCharacter,
240243
this.hintStyle,
241244
this.textGradient,
245+
this.readOnly = false,
242246

243247
/// Default for [AutofillGroup]
244248
this.onAutoFillDisposeAction = AutofillContextAction.commit,
@@ -537,9 +541,10 @@ class _PinCodeTextFieldState extends State<PinCodeTextField>
537541
);
538542
}
539543

540-
final text = widget.obscureText && _inputList[index].isNotEmpty && showObscured
541-
? widget.obscuringCharacter
542-
: _inputList[index];
544+
final text =
545+
widget.obscureText && _inputList[index].isNotEmpty && showObscured
546+
? widget.obscuringCharacter
547+
: _inputList[index];
543548
return widget.textGradient != null
544549
? Gradiented(
545550
gradient: widget.textGradient!,
@@ -738,6 +743,7 @@ class _PinCodeTextFieldState extends State<PinCodeTextField>
738743
: 0.01, // it is a hidden textfield which should remain transparent and extremely small
739744
),
740745
scrollPadding: widget.scrollPadding,
746+
readOnly: widget.readOnly,
741747
);
742748

743749
return SlideTransition(

0 commit comments

Comments
 (0)