You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need now to get an import statement when I reproduce the call method when generating code in my library builder, otherwise a reference to Cat will be missing. I can do this in the generator:
You can get an AssetId through the assetIdForElement api which would give you a bit more directly what you need.
That has a uri getter, but it will only give an "importable" uri if it can be mapped to a package: uri. If it comes from something outside of a lib directory you would have to construct a relative path to it using the path property of the asset id.
I am generating code from a function
I need now to get an import statement when I reproduce the call method when generating code in my library builder, otherwise a reference to
Cat
will be missing. I can do this in the generator:callMethod.type.returnType.element.location
which produces something like
asset:example/test/Cat.dart;asset:example/test/Cat.dart;Cat
I would then have to do some string manipulation to get the bits I want to create an import statment. Is this best practice or is there an easier way?
The text was updated successfully, but these errors were encountered: