diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index f5b00e33a0..cf77aff62b 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -1368,7 +1368,6 @@ static FlutterAutofillType autofillTypeOf(NSDictionary* configuration) { // It seems impossible to use a negative "width" or "height", as the "convertRect" // call always turns a CGRect's negative dimensions into non-negative values, e.g., // (1, 2, -3, -4) would become (-2, -2, 3, 4). - NSAssert(!_isFloatingCursorActive, @"Another floating cursor is currently active."); _isFloatingCursorActive = true; [self.textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateStart withClient:_textInputClient @@ -1376,16 +1375,13 @@ static FlutterAutofillType autofillTypeOf(NSDictionary* configuration) { } - (void)updateFloatingCursorAtPoint:(CGPoint)point { - NSAssert(_isFloatingCursorActive, - @"updateFloatingCursorAtPoint is called without an active floating cursor."); + _isFloatingCursorActive = true; [self.textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateUpdate withClient:_textInputClient withPosition:@{@"X" : @(point.x), @"Y" : @(point.y)}]; } - (void)endFloatingCursor { - NSAssert(_isFloatingCursorActive, - @"endFloatingCursor is called without an active floating cursor."); _isFloatingCursorActive = false; [self.textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateEnd withClient:_textInputClient diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index de6e549d10..e8a992ee0a 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -825,6 +825,16 @@ FLUTTER_ASSERT_ARC } } +- (void)testFloatingCursorDoesNotThrow { + // The keyboard implementation may send unbalanced calls to the input view. + FlutterTextInputView* inputView = [[FlutterTextInputView alloc] init]; + [inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)]; + [inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)]; + [inputView endFloatingCursor]; + [inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)]; + [inputView endFloatingCursor]; +} + - (void)testBoundsForFloatingCursor { FlutterTextInputView* inputView = [[FlutterTextInputView alloc] init];