istornz / flutter_live_activities

A Flutter plugin to use iOS 16.1+ Live Activities ⛹ī¸ & iPhone Dynamic Island 🏝ī¸ features
https://dimitridessus.fr/
MIT License
175 stars 54 forks source link

Is it possible to use SVG images? #74

Closed lazarohcm closed 7 months ago

lazarohcm commented 8 months ago

Sorry if this is not the right place, but I've looked everywhere and couldn't find an answer.

As the title says, I'm wondering if I can use an SVG image and display it in the live activity? I currently have an implementation that works fine with .png, but I'm not able to make it display .svg?

This is how the code looks like:

if let venueImageAssest = UIImage(contentsOfFile: venueImage)
{
    Image(uiImage: venueImageAssest)
        .resizable()
}

venueImage is currently an LiveActivityImageFromUrl

Any help is much appreciated, thanks!

istornz commented 8 months ago

Hello @lazarohcm, It seems you need to add an external Swift library to display it 👍

https://stackoverflow.com/a/74203993/5078902

fabiototh commented 8 months ago
  1. Add the package: SVGKit -> https://github.com/SVGKit/SVGKit
  2. import SVGKit
  3. if let uiYourLogo = SVGKImage(contentsOfFile: yourLogo)
  4. inside the brackets Image(uiImage: uiYourLogo.uiImage)