flutter_carplay icon indicating copy to clipboard operation
flutter_carplay copied to clipboard

FCPListItem does not support imageUrl

Open vanlooverenkoen opened this issue 2 years ago • 3 comments

Current implementation to set an image to a listItem is using an asset

    if image != nil {
      listItem.setImage(UIImage().fromFlutterAsset(name: image!))
    }

It should be possible to also use a HTTPs link to an image so we don't need to ship every image in assets

vanlooverenkoen avatar Sep 14 '22 08:09 vanlooverenkoen

Hi @vanlooverenkoen I was able to load list items with image url by doing the following.

  1. Open the flutter iOS project in XCODE

  2. Open the PODS->Development Pods->flutter_carplay

  3. Open the preceding .. unto the last directory, you will find flutter_carplay->Classes->Models -> Lists

  4. Navigate to FCPListItem.

  5. Find the codes:

  6. if image != nil { ... 7.Replace with : ` if image != nil { if image!.starts(with: "http"){

         let url = URL(string: image!)
         let stationImage = try? UIImage(withURL: url!)
    
         listItem.setImage(stationImage)
     }else{
         listItem.setImage(UIImage().fromFlutterAsset(name: image!))
     }
    

    }`

  7. Inside update, do the same. This will intercept all urls beginning with http with custom loader and those beginning with any other format as asset images. Thank you.

bensalcie avatar Oct 18 '22 08:10 bensalcie

Yes indeed that is why a pull request implementing this feature a month ago. #24

vanlooverenkoen avatar Oct 18 '22 13:10 vanlooverenkoen

flutter: Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction , After loading images from ulr i got this error and the mobile app ui freezes .

harryandroiddev avatar Aug 02 '23 04:08 harryandroiddev