diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml
index 51db6e8..5e2f2c6 100644
--- a/.idea/libraries/Dart_Packages.xml
+++ b/.idea/libraries/Dart_Packages.xml
@@ -5,174 +5,182 @@
-
+
-
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml
index 22ebdc2..b6e6985 100644
--- a/.idea/libraries/Dart_SDK.xml
+++ b/.idea/libraries/Dart_SDK.xml
@@ -1,27 +1,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b646b67..4929d34 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -20,7 +20,6 @@
-
@@ -30,7 +29,6 @@
-
-
+
+
+
+
+
+
-
+
@@ -74,10 +77,6 @@
-
-
-
-
@@ -91,8 +90,16 @@
+
+
+
+
+
+
+
+
@@ -103,6 +110,7 @@
+
@@ -337,6 +345,7 @@
+
diff --git a/android/local.properties b/android/local.properties
new file mode 100644
index 0000000..b3805e7
--- /dev/null
+++ b/android/local.properties
@@ -0,0 +1,2 @@
+sdk.dir=/Users/fabio/Library/Android/sdk
+flutter.sdk=/Users/fabio/flutter
\ No newline at end of file
diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh
new file mode 100755
index 0000000..3f8ff41
--- /dev/null
+++ b/example/ios/Flutter/flutter_export_environment.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# This is a generated file; do not edit or check into version control.
+export "FLUTTER_ROOT=/Users/fabio/flutter"
+export "FLUTTER_APPLICATION_PATH=/Users/fabio/LAVORO/Library/pin_code_text_field/example"
+export "COCOAPODS_PARALLEL_CODE_SIGN=true"
+export "FLUTTER_TARGET=lib/main.dart"
+export "FLUTTER_BUILD_DIR=build"
+export "FLUTTER_BUILD_NAME=1.0.0"
+export "FLUTTER_BUILD_NUMBER=1"
+export "DART_OBFUSCATION=false"
+export "TRACK_WIDGET_CREATION=false"
+export "TREE_SHAKE_ICONS=false"
+export "PACKAGE_CONFIG=.dart_tool/package_config.json"
diff --git a/example/lib/main.dart b/example/lib/main.dart
index da16586..8e5e2c5 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -128,7 +128,7 @@ class _MyAppState extends State {
children: [
Padding(
padding: const EdgeInsets.only(bottom: 60.0),
- child: Text(thisText, style: Theme.of(context).textTheme.title),
+ child: Text(thisText, style: Theme.of(context).textTheme.titleMedium),
),
Container(
height: 100.0,
@@ -169,6 +169,11 @@ class _MyAppState extends State {
highlightColor: Colors.blue,
defaultBorderColor: Colors.black,
hasTextBorderColor: Colors.green,
+ /**
+ * Fix error in library
+ */
+ pinBoxColor: Colors.transparent,
+ highlightPinBoxColor: Colors.transparent,
maxLength: pinLength,
hasError: hasError,
maskCharacter: "😎",
diff --git a/lib/pin_code_text_field.dart b/lib/pin_code_text_field.dart
index 7b483b6..1b5bfcf 100644
--- a/lib/pin_code_text_field.dart
+++ b/lib/pin_code_text_field.dart
@@ -1,10 +1,7 @@
import 'dart:async';
-
-import 'package:flutter/animation.dart';
import 'package:flutter/cupertino.dart' show CupertinoTextField;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
-import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
typedef OnDone = void Function(String text);
@@ -36,7 +33,7 @@ class ProvidedPinBoxDecoration {
static PinBoxDecoration underlinedPinBoxDecoration = (Color borderColor,
Color pinBoxColor, {
double borderWidth = 2.0,
- double radius,
+ double radius = 0,
}) {
return BoxDecoration(
border: Border(
@@ -51,7 +48,7 @@ class ProvidedPinBoxDecoration {
static PinBoxDecoration roundedPinBoxDecoration = (Color borderColor,
Color pinBoxColor, {
double borderWidth = 2.0,
- double radius,
+ double radius = 0,
}) {
return BoxDecoration(
border: Border.all(
@@ -107,42 +104,44 @@ class ProvidedPinBoxTextAnimation {
class PinCodeTextField extends StatefulWidget {
final bool isCupertino;
final int maxLength;
- final TextEditingController controller;
+ final TextEditingController? controller;
final bool hideCharacter;
final bool highlight;
final bool highlightAnimation;
final Color highlightAnimationBeginColor;
final Color highlightAnimationEndColor;
- final Duration highlightAnimationDuration;
+ final Duration? highlightAnimationDuration;
final Color highlightColor;
final Color defaultBorderColor;
- final Color pinBoxColor;
- final Color highlightPinBoxColor;
+ final Color? pinBoxColor;
+ final Color? highlightPinBoxColor;
final double pinBoxBorderWidth;
final double pinBoxRadius;
final bool hideDefaultKeyboard;
- final PinBoxDecoration pinBoxDecoration;
+ final PinBoxDecoration? pinBoxDecoration;
final String maskCharacter;
- final TextStyle pinTextStyle;
+ final TextStyle? pinTextStyle;
final double pinBoxHeight;
final double pinBoxWidth;
final OnDone? onDone;
final bool hasError;
final Color errorBorderColor;
final Color hasTextBorderColor;
- final Function(String) onTextChanged;
+ final Function(String)? onTextChanged;
final bool autofocus;
- final FocusNode focusNode;
- final AnimatedSwitcherTransitionBuilder pinTextAnimatedSwitcherTransition;
+ final FocusNode? focusNode;
+ final AnimatedSwitcherTransitionBuilder? pinTextAnimatedSwitcherTransition;
final Duration pinTextAnimatedSwitcherDuration;
final WrapAlignment wrapAlignment;
final TextDirection textDirection;
final TextInputType keyboardType;
final EdgeInsets pinBoxOuterPadding;
final bool hasUnderline;
+ //final TextCapitalization? textCapitalization;
+ final List? inputFormatter;
const PinCodeTextField({
- Key key,
+ Key? key,
this.isCupertino: false,
this.maxLength: 4,
this.controller,
@@ -178,6 +177,8 @@ class PinCodeTextField extends StatefulWidget {
this.pinBoxRadius = 0,
this.hideDefaultKeyboard = false,
this.hasUnderline = false,
+ //this.textCapitalization
+ this.inputFormatter
}) : super(key: key);
@override
@@ -188,14 +189,14 @@ class PinCodeTextField extends StatefulWidget {
class PinCodeTextFieldState extends State
with SingleTickerProviderStateMixin {
- AnimationController _highlightAnimationController;
- Animation _highlightAnimationColorTween;
- FocusNode focusNode;
+ AnimationController? _highlightAnimationController;
+ Animation? _highlightAnimationColorTween;
+ FocusNode? focusNode;
String text = "";
int currentIndex = 0;
List strList = [];
bool hasFocus = false;
- double screenWidth;
+ double screenWidth = 0;
@override
void didUpdateWidget(PinCodeTextField oldWidget) {
@@ -240,18 +241,18 @@ class PinCodeTextFieldState extends State
vsync: this,
duration:
widget.highlightAnimationDuration ?? Duration(milliseconds: 500));
- _highlightAnimationController.addStatusListener((status) {
+ _highlightAnimationController?.addStatusListener((status) {
if (status == AnimationStatus.completed) {
- _highlightAnimationController.reverse();
+ _highlightAnimationController?.reverse();
} else if (status == AnimationStatus.dismissed) {
- _highlightAnimationController.forward();
+ _highlightAnimationController?.forward();
}
});
_highlightAnimationColorTween = ColorTween(
begin: widget.highlightAnimationBeginColor,
end: widget.highlightAnimationEndColor)
- .animate(_highlightAnimationController);
- _highlightAnimationController.forward();
+ .animate(_highlightAnimationController!);
+ _highlightAnimationController?.forward();
}
focusNode = widget.focusNode ?? FocusNode();
@@ -268,7 +269,7 @@ class PinCodeTextFieldState extends State
});
if (widget.onTextChanged != null) {
- widget.onTextChanged(widget.controller.text);
+ widget.onTextChanged!(widget.controller!.text);
}
}
}
@@ -276,7 +277,9 @@ class PinCodeTextFieldState extends State
void _focusListener() {
if (mounted == true) {
setState(() {
- hasFocus = focusNode.hasFocus;
+ if(focusNode != null) {
+ hasFocus = focusNode!.hasFocus;
+ }
});
}
}
@@ -286,15 +289,17 @@ class PinCodeTextFieldState extends State
return;
}
strList.clear();
- if (widget.controller.text.isNotEmpty) {
- if (widget.controller.text.length > widget.maxLength) {
- throw Exception("TextEditingController length exceeded maxLength!");
+ if(widget.controller != null) {
+ if (widget.controller!.text.isNotEmpty) {
+ if (widget.controller!.text.length > widget.maxLength) {
+ throw Exception("TextEditingController length exceeded maxLength!");
+ }
}
- }
- text = widget.controller.text;
- for (var i = 0; i < text.length; i++) {
- strList.add(widget.hideCharacter ? widget.maskCharacter : text[i]);
+ text = widget.controller!.text;
+ for (var i = 0; i < text.length; i++) {
+ strList.add(widget.hideCharacter ? widget.maskCharacter : text[i]);
+ }
}
}
@@ -303,12 +308,12 @@ class PinCodeTextFieldState extends State
for (var i = 0; i < widget.maxLength; i++) {
width += widget.pinBoxWidth;
if (i == 0) {
- width += widget.pinBoxOuterPadding?.left ?? 0;
+ width += widget.pinBoxOuterPadding.left ?? 0;
} else if (i + 1 == widget.maxLength) {
- width += widget.pinBoxOuterPadding?.right ?? 0;
+ width += widget.pinBoxOuterPadding.right ?? 0;
} else {
- width += widget.pinBoxOuterPadding?.left ??
- 0 + widget.pinBoxOuterPadding?.right ??
+ width += widget.pinBoxOuterPadding.left ??
+ 0 + widget.pinBoxOuterPadding.right ??
0;
}
}
@@ -322,7 +327,7 @@ class PinCodeTextFieldState extends State
// in focus node as it's owned by the parent not this child widget.
focusNode?.dispose();
} else {
- focusNode.removeListener(_focusListener);
+ focusNode!.removeListener(_focusListener);
}
_highlightAnimationController?.dispose();
widget.controller?.removeListener(_controllerListener);
@@ -359,6 +364,19 @@ class PinCodeTextFieldState extends State
);
}
+ List _generateInputFormatter() {
+ List inputFormatters = [];
+ if(widget.keyboardType == TextInputType.number) {
+ inputFormatters.add(FilteringTextInputFormatter.digitsOnly);
+ }
+ if(widget.inputFormatter != null) {
+ widget.inputFormatter!.forEach((element) {
+ inputFormatters.add(element) ; //UpperCaseTextFormatter());
+ });
+ }
+ return inputFormatters;
+ }
+
Widget _fakeTextInput() {
var transparentBorder = OutlineInputBorder(
borderSide: BorderSide(
@@ -372,13 +390,12 @@ class PinCodeTextFieldState extends State
child: TextField(
autofocus: !kIsWeb ? widget.autofocus : false,
enableInteractiveSelection: false,
+ //textCapitalization: (widget.textCapitalization) != null?TextCapitalization.none:widget.textCapitalization!,
focusNode: focusNode,
controller: widget.controller,
keyboardType: widget.keyboardType,
- inputFormatters: widget.keyboardType == TextInputType.number
- ? [WhitelistingTextInputFormatter.digitsOnly]
- : null,
- style: TextStyle(
+ inputFormatters: _generateInputFormatter(),
+ style: const TextStyle(
height: 0.1, color: Colors.transparent,
// color: Colors.transparent,
),
@@ -415,9 +432,10 @@ class PinCodeTextFieldState extends State
focusNode: focusNode,
controller: widget.controller,
keyboardType: widget.keyboardType,
- inputFormatters: widget.keyboardType == TextInputType.number
- ? [WhitelistingTextInputFormatter.digitsOnly]
- : null,
+ inputFormatters: _generateInputFormatter(),
+ /*inputFormatters: widget.keyboardType == TextInputType.number
+ ? [FilteringTextInputFormatter.digitsOnly]
+ : null,*/
style: TextStyle(
color: Colors.transparent,
),
@@ -435,7 +453,7 @@ class PinCodeTextFieldState extends State
void _onTextChanged(text) {
if (widget.onTextChanged != null) {
- widget.onTextChanged(text);
+ widget.onTextChanged!(text);
}
setState(() {
this.text = text;
@@ -470,32 +488,32 @@ class PinCodeTextFieldState extends State
Widget _buildPinCode(int i, BuildContext context) {
Color borderColor;
- Color pinBoxColor;
+ Color pinBoxColor = Colors.transparent;
BoxDecoration boxDecoration;
if (widget.hasError) {
borderColor = widget.errorBorderColor;
} else if (widget.highlightAnimation && _shouldHighlight(i)) {
- pinBoxColor = widget.pinBoxColor;
+ pinBoxColor = widget.pinBoxColor!;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 4.0),
child: AnimatedBuilder(
- animation: _highlightAnimationController,
- builder: (BuildContext context, Widget child) {
- if (widget.pinBoxDecoration != null) {
- boxDecoration = widget.pinBoxDecoration(
- _highlightAnimationColorTween.value,
+ animation: _highlightAnimationController!,
+ builder: (BuildContext context, Widget? child) {
+
+ if(widget.pinBoxDecoration != null) {
+ boxDecoration = widget.pinBoxDecoration!(
+ _highlightAnimationColorTween!.value,
pinBoxColor,
borderWidth: widget.pinBoxBorderWidth,
radius: widget.pinBoxRadius,
);
} else {
- boxDecoration =
- ProvidedPinBoxDecoration.defaultPinBoxDecoration(
- _highlightAnimationColorTween.value,
- pinBoxColor,
- borderWidth: widget.pinBoxBorderWidth,
- radius: widget.pinBoxRadius,
- );
+ boxDecoration = ProvidedPinBoxDecoration.defaultPinBoxDecoration(
+ _highlightAnimationColorTween!.value,
+ pinBoxColor,
+ borderWidth: widget.pinBoxBorderWidth,
+ radius: widget.pinBoxRadius,
+ );
}
return Container(
@@ -508,17 +526,17 @@ class PinCodeTextFieldState extends State
}));
} else if (widget.highlight && _shouldHighlight(i)) {
borderColor = widget.highlightColor;
- pinBoxColor = widget.highlightPinBoxColor;
+ pinBoxColor = widget.highlightPinBoxColor!;
} else if (i < text.length) {
borderColor = widget.hasTextBorderColor;
- pinBoxColor = widget.highlightPinBoxColor;
+ pinBoxColor = widget.highlightPinBoxColor!;
} else {
borderColor = widget.defaultBorderColor;
- pinBoxColor = widget.pinBoxColor;
+ pinBoxColor = widget.pinBoxColor!;
}
if (widget.pinBoxDecoration != null) {
- boxDecoration = widget.pinBoxDecoration(
+ boxDecoration = widget.pinBoxDecoration!(
borderColor,
pinBoxColor,
borderWidth: widget.pinBoxBorderWidth,
@@ -601,3 +619,13 @@ class PinCodeTextFieldState extends State
}
}
}
+
+class UpperCaseTextFormatter extends TextInputFormatter {
+ @override
+ TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
+ return TextEditingValue(
+ text: newValue.text.toUpperCase(),
+ selection: newValue.selection,
+ );
+ }
+}
\ No newline at end of file
diff --git a/pubspec.lock b/pubspec.lock
index bd50f82..7d27b51 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -7,42 +7,49 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.4.1"
+ version: "2.8.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
+ version: "2.1.0"
+ characters:
+ dependency: transitive
+ description:
+ name: characters
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.3"
+ version: "1.3.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.1"
+ version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
- version: "1.14.12"
+ version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
@@ -59,21 +66,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.6"
+ version: "0.12.11"
+ material_color_utilities:
+ dependency: transitive
+ description:
+ name: material_color_utilities
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.4"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.8"
+ version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.7.0"
+ version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
@@ -85,55 +99,48 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.7.0"
+ version: "1.8.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
- version: "1.9.3"
+ version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.0"
+ version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.5"
+ version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.16"
- typed_data:
- dependency: transitive
- description:
- name: typed_data
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.1.6"
+ version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
- version: "2.0.8"
+ version: "2.1.2"
sdks:
- dart: ">=2.7.0 <3.0.0"
+ dart: ">=2.17.0-0 <3.0.0"