From 006cbb6b7553c9ec293758111055ffc6bbbd619f Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Tue, 7 Jan 2025 16:08:59 +0100 Subject: [PATCH] fix: ImpaktfullUiInputField now correctly handles the focus (removed duplicate events) --- .flutter-plugins-dependencies | 2 +- CHANGELOG.md | 6 ++++++ lib/src/components/input_field/input_field.dart | 12 +++++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index b84996f..389b8aa 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"android":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"macos":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"linux":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"windows":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"web":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","dependencies":[]}]},"dependencyGraph":[{"name":"rive_common","dependencies":[]}],"date_created":"2025-01-07 14:54:11.015245","version":"3.24.4","swift_package_manager_enabled":false} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"android":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"macos":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"linux":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"windows":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","native_build":true,"dependencies":[]}],"web":[{"name":"rive_common","path":"/Users/vanlooverenkoen/.pub-cache/hosted/pub.dev/rive_common-0.4.11/","dependencies":[]}]},"dependencyGraph":[{"name":"rive_common","dependencies":[]}],"date_created":"2025-01-07 15:15:40.570434","version":"3.24.4","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index eb75dc2..3e53cc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.28.1 + +## Fix + +- ImpaktfullUiInputField now correctly handles the focus (removed duplicate events) + # 0.28.0 ## Feat diff --git a/lib/src/components/input_field/input_field.dart b/lib/src/components/input_field/input_field.dart index 0b1703c..f3696e4 100644 --- a/lib/src/components/input_field/input_field.dart +++ b/lib/src/components/input_field/input_field.dart @@ -96,7 +96,6 @@ class _ImpaktfullUiInputFieldState extends State { _controller = widget.controller ?? TextEditingController(text: widget.value); _focusNode = widget.focusNode ?? FocusNode(); - _focusNode.addListener(_onFocusChanged); if (widget.autofocus) { WidgetsBinding.instance.addPostFrameCallback((_) { _focusNode.requestFocus(); @@ -120,7 +119,6 @@ class _ImpaktfullUiInputFieldState extends State { if (widget.controller == null) { _controller.dispose(); } - _focusNode.removeListener(_onFocusChanged); if (widget.focusNode == null) { _focusNode.dispose(); } @@ -259,7 +257,7 @@ class _ImpaktfullUiInputFieldState extends State { placeholder: widget.placeholder, autofocus: widget.autofocus, multiline: widget.multiline, - onFocusChanged: widget.onFocusChanged, + onFocusChanged: _onFocusChanged, readOnly: widget.readOnly, textAlign: widget.textAlign, ), @@ -310,7 +308,7 @@ class _ImpaktfullUiInputFieldState extends State { void _onFocus() => _focusNode.requestFocus(); - void _onFocusChanged() { + void _onFocusChanged(bool hasFocus) { final hasFocus = _focusNode.hasFocus; final controller = widget.controller; if (hasFocus && @@ -329,9 +327,9 @@ class _ImpaktfullUiInputFieldState extends State { void _onSubmitFromVirtualKeyboard() { Navigator.pop(context); - final onChanged = widget.onChanged; - if (onChanged == null) return; - onChanged(_controller.text); + final onSubmit = widget.onSubmit; + if (onSubmit == null) return; + onSubmit(_controller.text); } void _onObscureTextHideShowIconTapped() {