AbdulRahmanAlHamali / flutter_typeahead

A TypeAhead widget for Flutter, where you can show suggestions to users as they type
BSD 2-Clause "Simplified" License
823 stars 344 forks source link

[Bug] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil' #605

Open AdamTechAcc opened 3 weeks ago

AdamTechAcc commented 3 weeks ago

Steps to reproduce

I have an app with registration screens. When for example 3rd screen has TypeAheadField and we go through to the end of registration process and back to starting screen:

Navigator.of(context).pushNamedAndRemoveUntil(StartScreen.routeName, (Route<dynamic> route) => false);

Then when we reload app by clicking 'Play' button in Android Studio and trying to go to the screen with TypeAheadField problem occurs. App freezed between screens route animation. When I do not reload app everything works fine. Also when I don't use TypeAheadField everything works.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x18ca0908c ...)
libc++abi: terminating due to uncaught exception of type NSException  

Problem is even for just that TypeAheadField configuration:

      TypeAheadField<String>(
            builder: (context, controller, focusNode) => Text('aaaaaa'),
            itemBuilder: (context, String suggestion) => Text('item'),
            suggestionsCallback: (pattern) => ['aaaaaaaa'],
            onSelected: (x) {},
          ),
❯ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0 24A335 darwin-arm64, locale pl-PL)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.92.2)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Expected results

No internal error

Actual results

App crashes with Terminating app due to uncaught exception 'NSInvalidArgumentException'

Package Version

5.2.0

Platform

iOS

Code sample

Code sample ```dart [Paste your code here] ```

Logs

Logs ```console [Paste your logs here] ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]
venbrinoDev commented 19 hours ago

Just encounter this bug

any fix ?