diff --git a/CHANGELOG.md b/CHANGELOG.md index 23ad99c..320d55c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [0.1.2] 19.09.2022 + +* Fixed a bug where it was impossible to delete text content or text content reappears after deletion +* Added stream subscription into didUpdateWidget controller. [thanks @sipanpetrosyan] + ## [0.1.1] 13.09.2022 * Added emoji detection support [thanks @moazh] diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..9625e10 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index deb66de..30b6524 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -272,7 +272,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -346,7 +346,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -395,7 +395,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index a060db6..1579fb3 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -41,5 +41,7 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/example/lib/default_controller_above.example.dart b/example/lib/default_controller_above.example.dart index dbe1a7b..796e846 100644 --- a/example/lib/default_controller_above.example.dart +++ b/example/lib/default_controller_above.example.dart @@ -88,6 +88,7 @@ class _DefaultControllerAboveExampleScreenState extends State=2.14.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.17.0" diff --git a/lib/controller/social_text_editing_controller.dart b/lib/controller/social_text_editing_controller.dart index 6a8d3d5..19bd213 100644 --- a/lib/controller/social_text_editing_controller.dart +++ b/lib/controller/social_text_editing_controller.dart @@ -68,7 +68,9 @@ class SocialTextEditingController extends TextEditingController{ if(currentPosition == -1){ currentPosition = 0; } - + if(currentPosition >newValue.text.length){ + currentPosition = newValue.text.length - 1; + } var subString = newValue.text.substring(0,currentPosition); var lastPart = subString.split(" ").last.split("\n").last; @@ -105,6 +107,4 @@ class SocialTextEditingController extends TextEditingController{ TextSpan buildTextSpan({required BuildContext context, TextStyle? style, required bool withComposing}) { return SocialTextSpanBuilder(regularExpressions: _regularExpressions,defaultTextStyle: style,detectionTextStyles: detectionTextStyles).build(text); } - - } \ No newline at end of file diff --git a/lib/widget/social_text_field_controller.dart b/lib/widget/social_text_field_controller.dart index 4fd7032..90eb03e 100644 --- a/lib/widget/social_text_field_controller.dart +++ b/lib/widget/social_text_field_controller.dart @@ -78,8 +78,12 @@ class _DefaultSocialTextFieldControllerState @override void didUpdateWidget(covariant DefaultSocialTextFieldController oldWidget) { super.didUpdateWidget(oldWidget); - _streamSubscription = - widget.textEditingController.subscribeToDetection(onDetectContent); + _subscribeToStreamIfNeeded(); + } + + void _subscribeToStreamIfNeeded() async{ + await _streamSubscription?.cancel(); + _streamSubscription = widget.textEditingController.subscribeToDetection(onDetectContent); } ///Shows the widget that hes been set with the [widget.detectionBuilders]. return empty Container if noting found @@ -147,7 +151,7 @@ class _DefaultSocialTextFieldControllerState if (!(renderObject is RenderBox)) { return 0.0; } - RenderBox box = renderObject as RenderBox; + RenderBox box = renderObject; Offset position = box.localToGlobal(Offset.zero); //this is global position double y = position.dy; // return MediaQuery.of(context).size.height - y; diff --git a/pubspec.lock b/pubspec.lock index 6d50853..60cce15 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.9.0" boolean_selector: dependency: transitive description: @@ -21,35 +21,28 @@ packages: 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.3.1" + version: "1.2.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -66,21 +59,28 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.12" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.5" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -92,7 +92,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" stack_trace: dependency: transitive description: @@ -113,35 +113,28 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.17.0" diff --git a/pubspec.yaml b/pubspec.yaml index c27ac36..4d1626b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_social_textfield description: TextEditingController and RichText / TextSpan builder with hashtag, url and mention detection with Regular Expressions. Also with tap support. -version: 0.1.1 +version: 0.1.2 homepage: https://github.com/dreampowder/flutter_social_textfield environment: