-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request for Access to Plugin Code in Unit Tests for Better Native Code Testing #60323
Comments
I'm not sure what Dart feature would help with this (or what a Flutter plugin is at all). |
In my experience, @lrhn requests on Flutter's repo are useless. It's just a constant fight not to get the issue set as a duplicate on some vaguely related issues. Flutter plugin might be the wrong name. it's just a package that calls native code using usually "Platform Channels". |
I think Platform Channels is a Flutter thing too. The Dart approach to calling native code is |
In a sense, the solution for this issue is what is being worked on in dart-lang/native. IIUC the end goal is to have good enough support for autogenerated bindings for native APIs (which directly call those APIs through |
Sorry for my limited understanding of the subject. In my mind dart::ffi is a way to call C functions while platform Chanel is way to call swift code on iOS (and probably Kotlin on android) I'm surprise this binding mechanism is not provided by the languages/compiler and is flutter specific. I'm also surprised that the flutter project seems to have it's own stuff regarding binding and testing. The main issue here is "flutter test" doesn't call native code and when you start mocking the native code that do the work you are actually not testing anything But I guess "dart test" would not have the same limitations? |
The packages in If you use these bindings you will always directly call the native APIs regardless of whether running with But note that these tools are not stable yet, and it will probably take a bit more time until they are. |
Plugin packages are a Flutter-specific extension to Dart packages that (among other things) compiles native code in the package into the resulting Flutter app, by grafting it into the Flutter build system. There is no Dart feature that would allow accessing the native code in a plugin because without The in-progress native assets feature would provide an alternative whose output
Correct; platform channels are defined and implemented entirely at the Flutter level. |
This is only sort of true. If you are using |
@stuartmorgan would you be able to explain why "flutter test" doesn't give you access to platform channels? Does this mecanism use dart::ffi under the hood? ———- I also would like to apologize for a conversation we had on the Flutter repo, As described above, I have been frustrated with the Flutter repo issue system and I ended up sharing this frustration with contributors, I was wrong doing so |
This is not the best repo for getting information about why The request, as written, is not a Dart issue. |
Description:
Currently, unit tests in Flutter do not provide a straightforward way to access and test native code used within plugins. This limitation forces developers to rely on either:
As a result, there is a gap in testing where developers cannot properly validate the integration and behavior of native code in isolation, slowing down development and making it harder to catch issues early in the development cycle.
Problem:
Proposed Solution:
I would like to request a feature where Flutter allows access to plugin code in unit tests, so we can test the native functionality directly in a more isolated and efficient manner.
Benefits:
I believe this feature would greatly improve the testing experience in Flutter and enable more reliable testing practices for developers working with native plugins.
The text was updated successfully, but these errors were encountered: