Fuelet / flutter_cloud_kit

MIT License
39 stars 17 forks source link

Support assets (CKAsset) #8

Open f-person opened 1 year ago

f-person commented 1 year ago

CloudKit has support for assets. It'd be nice to implement those into the package eventually. However, we'd need to figure out how to implement the linking for this to work.

Two ways currently come to my mind:

  1. Maintain the current CloudKitRecord.values structure (Map<String, dynamic>), add a new class for assets, check the values map for any CloudKitAsset values, and convert those to CKAssets on the platform side of the plugin.
  2. Reconsider the usage of dynamic maps for values altogether and develop something that would match CloudKit's field types. While this will add some inconvenience (e.g., using CKValue.int(12) instead of 12), we'll get more safety and won't be able to use types that aren't supported by CloudKit (e.g., nested maps, which are currently allowed by the Dart API but will fail when trying to use them).

I favor the second option more, but I need some background thinking to see what works best. I've also been thinking about code generation; not for this particular use case, but it may make syncing complex/large data easier while being the safer* way to design CloudKit models.

* I'm unsure if we can reach 100% yet; need to dig into CloudKit a little more for that

f-person commented 1 year ago

Going with the second option would also help with #2, #3 and #4 :)