jaumard / sms_autofill

Flutter plugin to provide SMS code autofill support
MIT License
281 stars 173 forks source link

Error with sms_autofill integration: "Type 'EditableTextContextMenuBuilder' not found." #183

Closed gandhiidhruvv closed 3 weeks ago

gandhiidhruvv commented 1 year ago

I encountered an issue while trying to integrate sms_autofill (version 2.2.0) into my project. The error message showed that the type "EditableTextContextMenuBuilder" was not found in the "pin_widget.dart" file.

The error message also stated that there is no named parameter with the name 'EditableTextContextMenuBuilder'.

../../Documents/software/flutter/.pub-cache/hosted/pub.dartlang.org/pin_input_text_field-4.4.0/lib/src/widget/pin_widget.dart:65:9: Error: Type 'EditableTextContextMenuBuilder' not found. final EditableTextContextMenuBuilder? contextMenuBuilder; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../Documents/software/flutter/.pub-cache/hosted/pub.dartlang.org/pin_input_text_field-4.4.0/lib/src/widget/pin_widget.dart:419:5: Error: Type 'EditableTextContextMenuBuilder' not found. EditableTextContextMenuBuilder? contextMenuBuilder, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../Documents/software/flutter/.pub-cache/hosted/pub.dartlang.org/pin_input_text_field-4.4.0/lib/src/widget/pin_widget.dart:65:9: Error: 'EditableTextContextMenuBuilder' isn't a type. final EditableText

while integrating sms_autofill, my project used the following dependencies:

version: 1.0.0+1 environment: sdk: '>=2.12.0 <3.0.0' dependencies: flutter: sdk: flutter get: ^4.6.5 connectivity_plus: ^2.3.6 shared_preferences: ^2.0.15 cached_network_image: ^3.2.1 flutter_svg: ^1.1.6 google_sign_in: ^5.0.7 flutter_switch: ^0.3.2 flutter_svg_provider: ^1.0.3 pin_code_fields: ^7.3.0 intl: ^0.17.0

Note that I did not use pin_input_text_field before, but the issue arose after adding sms_autofill to the project.

mahmoud-othmane commented 1 year ago

@gandhiidhruvv Until this is fixed, I think you can go around this by overriding the pin_input_text_field version to an older one on your app's pubspec.yaml file. Something like:

dependency_overrides:
  .
  .
  .
  pin_input_text_field: 4.2.0
gandhiidhruvv commented 1 year ago

@mahmoud-othmane thank you for your valuable suggestion, yesterday I also tried this solution, and its works for me. I forget to share my suggestion on this.

danishkhawaja98 commented 1 year ago

Hi @gandhiidhruvv I was facing this issue just right now and I just upgraded my flutter SDK to 3.7.2 and the issue was gone. Kindly upgrade your flutter SDK

Thanks

gandhiidhruvv commented 1 year ago

hello @danishkhawaja98 Thanks for update , will do it once PM get agree to update the version

danishkhawaja98 commented 1 year ago

@gandhiidhruvv Until this is fixed, I think you can go around this by overriding the pin_input_text_field version to an older one on your app's pubspec.yaml file. Something like:

dependency_overrides:
  .
  .
  .
  pin_input_text_field: 4.2.0

This is also the best approach if you are working with a team and your team uses the same flutter SDK.

jaumard commented 3 weeks ago

should be ok on 2.4.0

lybur commented 1 week ago

should be ok on 2.4.0

I'm still facing this issue on 2.4.0. The error message is as below: ../../.pub-cache/hosted/pub.dev/sms_autofill-2.4.0/lib/sms_autofill.dart:126:7: Error: No named parameter with the name 'contextMenuBuilder'. contextMenuBuilder: (context, editableTextState) { ^^^^^^^^^^^^^^^^^^ ../../.pub-cache/hosted/pub.dev/pin_input_text_field-4.2.0/lib/src/widget/pin_widget.dart:64:3: Context: Found this candidate, but the arguments don't match. PinInputTextField({ ^^^^^^^^^^^^^^^^^ Target kernel_snapshot failed: Exception

I am using Flutter SDK 3.16.5 and 3.2.3 Dart SDK and it's not working when I try to debug it on Android devices (I've tried Android 14 and Android 9) and an iPhone SE. I've also tried to add the dependency_overrides for pin_input_text_field: 4.2.0, but it's not working as well.

lybur commented 1 week ago

should be ok on 2.4.0

I'm still facing this issue on 2.4.0. The error message is as below: ../../.pub-cache/hosted/pub.dev/sms_autofill-2.4.0/lib/sms_autofill.dart:126:7: Error: No named parameter with the name 'contextMenuBuilder'. contextMenuBuilder: (context, editableTextState) { ^^^^^^^^^^^^^^^^^^ ../../.pub-cache/hosted/pub.dev/pin_input_text_field-4.2.0/lib/src/widget/pin_widget.dart:64:3: Context: Found this candidate, but the arguments don't match. PinInputTextField({ ^^^^^^^^^^^^^^^^^ Target kernel_snapshot failed: Exception

I am using Flutter SDK 3.16.5 and 3.2.3 Dart SDK and it's not working when I try to debug it on Android devices (I've tried Android 14 and Android 9) and an iPhone SE. I've also tried to add the dependency_overrides for pin_input_text_field: 4.2.0, but it's not working as well.

Resolved issue by adding dependency override as below:

dependency_overrides:
  .
  .
  .
  pin_input_text_field: 4.4.0
jaumard commented 1 week ago

@lybur this package don't enforce any specific version but a range pin_input_text_field: '>=4.2.0 <5.0.0' so upgrading your dependencies should do the trick, you shouldn't need to overrides anything

lybur commented 1 week ago

@lybur this package don't enforce any specific version but a range pin_input_text_field: '>=4.2.0 <5.0.0' so upgrading your dependencies should do the trick, you shouldn't need to overrides anything

I see, but no matter how many times I clear and clean the pub cache, it still uses pin_input_text_field 4.2.0. How does it decide which version to use?

lybur commented 1 week ago

@lybur this package don't enforce any specific version but a range pin_input_text_field: '>=4.2.0 <5.0.0' so upgrading your dependencies should do the trick, you shouldn't need to overrides anything

I see, but no matter how many times I clear and clean the pub cache, it still uses pin_input_text_field 4.2.0. How does it decide which version to use?

Ok I get it now, I should just edit the version in pubspec.lock. Thank you!

jaumard commented 1 week ago

did you try flutter pub upgrade ? By default it take the versions in your pubspec.lock, if there is none it take the last version on compatible on pub. pub upgrade should put 4.4.0 in your .lock and unlock you situation