Static methods/getters aren't generated correctly in dart
jquesada2016 opened this issue · comments
Describe the bug
Given the following code:
pub struct MyStruct {}
impl MyStruct {
pub fn my_function() {}
}
Does not output the MyStruct
class in dart, presumably because it's not being referenced anywhere else, but this is often needed for better code organization, rathern than relying solely on top-level functions.
Regarding getters
#[frb(opaque)]
pub struct MyStruct {}
impl MyStruct {
#[frb(sync)]
pub fn new() -> Self {
Self {}
}
#[frb(sync, getter)]
pub fn a() -> String {
"apple".into()
}
}
generates invalid dart code, because it tries to pass a hint parameter which doesn't exist in a getter
Steps to reproduce
- Copy/paste the above examples into a new project
- Run codegen
- Observe the errors from dart
Logs
N/A
Expected behavior
Static methods should always be generated on classes, even if the struct isn't part of a public API directly.
Static getters should be generated correctly.
Generated binding code
No response
OS
No response
Version of flutter_rust_bridge_codegen
No response
Flutter info
No response
Version of clang++
No response
Additional context
No response
This looks like a bug, I do expect them to work. Feel free to PR, alternatively I will fix in the next batch (possibly within several days)
(oops close by mistake)
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.