Skip to content

Commit

Permalink
fix focus/unfocus action not responsive sometimes (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
henryleunghk authored Dec 29, 2021
1 parent 6607fe7 commit 70b891a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.2.4

* fix focus action not working sometimes

## 1.2.3

* fix placeholder re-appeared upon widget rebuilt
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- Flutter (1.0.0)
- flutter_native_text_input (1.2.3):
- flutter_native_text_input (1.2.4):
- Flutter

DEPENDENCIES:
Expand All @@ -15,8 +15,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
flutter_native_text_input: 64d4cedbc245cc766a50bbbee93e29a3ea0595c3
flutter_native_text_input: 8d9586a82ca14b2bb437930b4041db9e9ff1a423

PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d

COCOAPODS: 1.11.2
COCOAPODS: 1.10.1
2 changes: 1 addition & 1 deletion ios/flutter_native_text_input.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
Pod::Spec.new do |s|
s.name = 'flutter_native_text_input'
s.version = '1.2.3'
s.version = '1.2.4'
s.summary = 'Native text input for Flutter'
s.description = <<-DESC
Native text input for Flutter
Expand Down
13 changes: 3 additions & 10 deletions lib/flutter_native_text_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ class _NativeTextInputState extends State<NativeTextInput> {
super.initState();

_effectiveFocusNode.addListener(() {
if (_effectiveFocusNode.hasFocus) {
_channel.invokeMethod("focus");
} else {
_channel.invokeMethod("unfocus");
}
_channel.invokeMethod(_effectiveFocusNode.hasFocus ? "focus" : "unfocus");
});

if (widget.controller != null) {
Expand Down Expand Up @@ -411,16 +407,13 @@ class _NativeTextInputState extends State<NativeTextInput> {
// input control methods
void _inputStarted() {
_scrollIntoView();
Future.delayed(const Duration(milliseconds: 1000)).then((value) {
if (!_effectiveFocusNode.hasFocus)
FocusScope.of(context).requestFocus(_effectiveFocusNode);
});
}

void _inputFinished(String? text) {
_channel.invokeMethod("unfocus");
if (_effectiveFocusNode.hasFocus) {
FocusScope.of(context).unfocus();
}
if (_effectiveFocusNode.hasFocus) FocusScope.of(context).unfocus();
if (widget.onSubmitted != null) {
Future.delayed(Duration(milliseconds: 100), () {
widget.onSubmitted!(text);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_native_text_input
description: Native text input for Flutter. Currently iOS-only with the use of UITextView.

version: 1.2.3
version: 1.2.4
homepage: https://github.com/henryleunghk/flutter-native-text-input

environment:
Expand Down

0 comments on commit 70b891a

Please sign in to comment.