0

I'm new to flutter so, please bear with me if this is a novice.

Is there a way to add handler for Method channel calls in dart code?

The samples and demo I referred to online all use the method channel to add handlers in native platforms. But none speaks about handling them in the flutter app itself.

Reason: There are already platform handlers for a fetching a image. but I need the same function to be done via an HTTP request from the app code.

Nikhileshwar
  • 1,666
  • 1
  • 11
  • 26
  • what is your problem actually? you call `_channel.invokeMethod('getimage', index)` from dart code and you got a list of something, so what is the problem with that list? – pskink Oct 22 '20 at 07:56
  • what for? do you call [invokeMethod](https://api.flutter.dev/javadoc/io/flutter/plugin/common/MethodChannel.html#invokeMethod-java.lang.String-java.lang.Object-) from java code? no, you call it from dart code... i am lost actually, what is your primary goal? – pskink Oct 22 '20 at 08:03
  • The need is to get images from the web client. Already the images are being fetched from the message channel for platform images. So now I thought of changing the channel for the scenario of fetching images from the web client and implementing a message channel listener in dart code to fetch the image from the web client. – Nikhileshwar Oct 22 '20 at 08:11
  • `"The need is to get images from the web client"` - so your method `final List images = await _channel.invokeMethod('getimage', index);` returns those images: it returns a `List` - its is not a list with images you want to get? – pskink Oct 22 '20 at 08:12
  • read this first https://flutter.dev/docs/development/platform-integration/platform-channels?tab=android-channel-java-tab#step-3-add-an-android-platform-specific-implementation – pskink Oct 22 '20 at 08:21
  • @pskink I have simplified the query now. – Nikhileshwar Oct 22 '20 at 11:21
  • @pskink I need to pass data **from** dart **to** dart. Already data is being passed from dart to java. – Nikhileshwar Oct 22 '20 at 11:53
  • Do you mean to check the passing of data from java to dart as a reference? I'll check that. – Nikhileshwar Oct 22 '20 at 11:56
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/223454/discussion-between-error-280-monkey-found-and-pskink). – Nikhileshwar Oct 22 '20 at 12:40

0 Answers0