'What is the best way to pass custom object array from native to flutter?
Currently, I am trying to pass custom object array from native to Flutter using EventChannel
.
What is the best way to pass custom object array from native to flutter?
Solution 1:[1]
Depends. If you want to pass the custom object array to the flutter side if some event occurs on the native side, using EventChannel is the way to go. If, however you want to initiate the passing of the custom object array from the flutter side, you should use a method channel. How to send the custom object array through the channels? Well, take a look at the documentation and be aware that you need to convert the list of custom objects to a list of maps on the native side and then convert it back to a list of custom objects on the flutter side, because platform channels only support specific data types. Docs: https://docs.flutter.dev/development/platform-integration/platform-channels?tab=type-mappings-swift-tab
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | TheUltimateOptimist |