deakjahn / sqflite_web

A web plugin for https://github.com/tekartik/sqflite
Other
36 stars 20 forks source link

Undefined name 'SqflitePluginWeb'. error in generated_plugin_registrant.dart #19

Closed masteradit closed 3 years ago

masteradit commented 3 years ago

I am getting this error in generated_plugin_registrant.dart file after adding sqflite_web.

Undefined name 'SqflitePluginWeb'.
Try correcting the name to one that is defined, or defining the name.dart(undefined_identifier)

Source code: https://github.com/masteradit/AllSQL

I have also created another issue (#18). Do you think they could be related to each other?

deakjahn commented 3 years ago

Do you experience anything similar with the example in the package? Does the message mean that you're unable to compile or is it just an IDE analysis warning that's a nuisance but doesn't keep you from compiling?

masteradit commented 3 years ago

Do you experience anything similar with the example in the package?

Yes, I am getting the same error:

Undefined name 'SqflitePluginWeb'.
Try correcting the name to one that is defined, or defining the name.dart(undefined_identifier)

Does the message mean that you're unable to compile or is it just an IDE analysis warning that's a nuisance but doesn't keep you from compiling?

I think it might be just an IDE analysis warning. However, when I ignore it and click on Debug anyway, the app gets stuck on Waiting for connection from debug service from Chrome (as mentioned in #18). The app works when I run it in release mode using flutter run --release.

deakjahn commented 3 years ago

I forgot to ask which IDE and probably, which platform. If you happen to be on Windows, you could also try Edge (no setup needed, as Edge uses Chrome's engine now, it just automatically works for debugging, too).

deakjahn commented 3 years ago

The false error probably comes from the fact that this is not an all-platform plugin (Android/iOS and web). The SqflitePluginWeb comes from a conditionally included file and the IDE is unable to recognize this. Until it can be turned into a full plugin (and the original Sqflite won't embrace it unless database persistence can be solved), this is unlikely to go away.

But that shouldn't be related to the other issue you experience.

deakjahn commented 3 years ago

Having said that above, it seems to me now that if you modify the example's pubspec.yaml by moving

sqflite_web:
  path: ../

inside dependencies rather than dev_dependencies, it might be better for this warning. Could you try this?

masteradit commented 3 years ago

I forgot to ask which IDE and probably, which platform.

I primarily use VS Code on Windows.

If you happen to be on Windows, you could also try Edge (no setup needed, as Edge uses Chrome's engine now, it just automatically works for debugging, too).

I tried using Edge too but got the same error.

The false error probably comes from the fact that this is not an all-platform plugin (Android/iOS and web).

Oh, okay.

I was searching "how to register with registrar flutter web plugin" and I came across Registrar class. Do you think this would help in any way?

masteradit commented 3 years ago

I found another article that may be useful: https://medium.com/flutter/how-to-write-a-flutter-web-plugin-5e26c689ea1. This article is a bit old but it shows how url_launcher_web was created.

The SqflitePluginWeb comes from a conditionally included file and the IDE is unable to recognize this.

I think now I understand what this means. In sqflite_web.dart file, src/sqflite_web.dart is imported if dart.library.html is true. Is this what you meant?

deakjahn commented 3 years ago

Yes. But with the modified .yaml as I uploaded, this seems to behave better for me now. Did you try it?

masteradit commented 3 years ago

Oh, I have been using sqflite_web in dependencies since the beginning (https://github.com/masteradit/AllSQL/blob/master/pubspec.yaml).

HowToSolutions commented 2 years ago

I had the same issue while using VS Code. My solution was to exclude lib/generated_plugin_registrant.dart file from code analysis.