flutter_typeahead icon indicating copy to clipboard operation
flutter_typeahead copied to clipboard

[Bug] Exception when using keyboard arrows to navigate list

Open pstrode opened this issue 7 months ago • 5 comments

Steps to reproduce

  1. Build and run the example project on Windows or Linux desktop. This also occurs on the Android emulator.
  2. Use the keyboard arrows to navigate up and down the list.

Expected results

No exceptions to be thrown when using arrow keys.

Actual results

The list updates correctly when navigating with the keyboard, but it still throws an error with each key press.

Package Version

5.0.1 - 7e3d31f

Platform

Android, Windows, Linux

Logs

Logs
══╡ EXCEPTION CAUGHT BY FOUNDATION LIBRARY ╞════════════════════════════════════════════════════════
The following assertion was thrown while dispatching notifications for
SuggestionsController<Product>:
RenderAbstractViewport.of() was called with a render object that was not a descendant of a
RenderAbstractViewport.
No RenderAbstractViewport render object ancestor could be found starting from the object that was
passed to RenderAbstractViewport.of().
The render object where the viewport search started was:
  RenderRepaintBoundary#b5016 relayoutBoundary=up15

When the exception was thrown, this was the stack:
#0      RenderAbstractViewport.of.<anonymous closure> (package:flutter/src/rendering/viewport.dart:68:9)
#1      RenderAbstractViewport.of (package:flutter/src/rendering/viewport.dart:78:6)
#2      ScrollPosition.ensureVisible (package:flutter/src/widgets/scroll_position.dart:800:68)
#3      _PagePosition.ensureVisible (package:flutter/src/widgets/page_view.dart:337:18)
#4      ScrollableState._performEnsureVisible (package:flutter/src/widgets/scrollable.dart:1038:55)
#5      Scrollable.ensureVisible (package:flutter/src/widgets/scrollable.dart:474:45)
#6      FocusTraversalPolicy.defaultTraversalRequestFocusCallback (package:flutter/src/widgets/focus_traversal.dart:181:16)
#7      DirectionalFocusTraversalPolicyMixin.inDirection (package:flutter/src/widgets/focus_traversal.dart:917:31)
#8      FocusNode.focusInDirection (package:flutter/src/widgets/focus_manager.dart:1161:91)
#9      _SuggestionsBoxTraversalConnectorState.onControllerFocus (package:flutter_typeahead/src/common/box/suggestions_box_traversal_connector.dart:52:19)
#10     ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24)
#11     SuggestionsController.focusBox (package:flutter_typeahead/src/common/base/suggestions_controller.dart:154:5)
#12     SuggestionsFieldTraversalConnector.onKeyEvent (package:flutter_typeahead/src/common/field/suggestions_field_traversal_connector.dart:25:20)
#13     SuggestionsFieldTraversalConnector.wrapOnKeyEvent.<anonymous closure> (package:flutter_typeahead/src/common/field/suggestions_field_traversal_connector.dart:41:31)
#14     _HighlightModeManager.handleKeyMessage (package:flutter/src/widgets/focus_manager.dart:1833:39)
#15     KeyEventManager._dispatchKeyMessage (package:flutter/src/services/hardware_keyboard.dart:996:34)
#16     KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:1061:17)
#17     BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:223:49)
#18     _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:567:35)
#19     _invoke2 (dart:ui/hooks.dart:344:13)
#20     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45:5)
#21     _Channel.push (dart:ui/channel_buffers.dart:135:31)
#22     ChannelBuffers.push (dart:ui/channel_buffers.dart:343:17)
#23     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:722:22)
#24     _dispatchPlatformMessage (dart:ui/hooks.dart:257:31)

The SuggestionsController<Product> sending notification was:
  Instance of 'SuggestionsController<Product>'
════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.
Another exception was thrown: RenderAbstractViewport.of() was called with a render object that was not a descendant of a RenderAbstractViewport.

pstrode avatar Dec 20 '23 17:12 pstrode

Thank you for your report. This problem is caused by an issue upstream.

https://github.com/flutter/flutter/issues/140547

clragon avatar Dec 22 '23 16:12 clragon

The issue has already been fixed on the master branch of the flutter sdk. We will have to wait for the next flutter release for this issue to resolve here.

clragon avatar Dec 29 '23 13:12 clragon

Today Flutter upgraded to 3.19.0 from 3.16.9. Error not throw, but focus not changed to next field, only the keyboard hide. I also add FocusScope.of(context).nextFocus(), but nothing happens.

textInputAction: TextInputAction.next,
onEditingComplete: () {
  FocusScope.of(context).nextFocus();
},

Poloten avatar Feb 20 '24 14:02 Poloten

+1 for this issue.

animator avatar Feb 28 '24 22:02 animator

Has anyone managed to navigate between the options with the arrow keys?

DessisInformatica avatar Mar 08 '24 22:03 DessisInformatica