Reputation: 218
I try to write a plugin for my Flutter project, I want to load an image from plugin Assets folder, do anyone know how can I load this frame.png from objective c native code?
I tried use: [[NSBundle mainBundle] pathForResource:@"frame" ofType:@"png"];
but it getting null. Anyone here know how to load this image?
Thanks
Upvotes: 4
Views: 1782
Reputation: 11
after updating your podspec as suggested by Ayan, you can use your image like this
```let image = UIImage(named: "image.png",
in: Bundle(for: YourPlugin.self),
compatibleWith: nil)```
Upvotes: 0
Reputation: 278
If you are developing a flutter plugin and need to have native assets these are the following things you have to do,
s.resources = 'Assets/*.png'
let bundle = Bundle(for: YourPlugin.self) let url = bundle.url(forResource: "frame", withExtension: "png")!
Upvotes: 3