How to send parameters to JAVA from DART using method channels. I am not able to send parameters to JAVA from DART using method channels. Please Please help . Error is attached below. What I am trying to do-->Dart(a,b)->Java(sum=a+b)->Dart(disp(sum))

492 views
Skip to first unread message

Spandan Bhandari

unread,
Sep 22, 2019, 4:52:19 AM9/22/19
to Flutter Development (flutter-dev)



After clicking the button I am getting below exceptions

Ryan Gonzalez

unread,
Sep 22, 2019, 11:48:48 PM9/22/19
to Spandan Bhandari, Flutter Dev
The map of arguments you're passing is:

<int, int>{
 a: 1,
 b: 2,
}

However, Dart isn't JS: keys in maps aren't automatically quoted. By this, I mean {a: 1} is not equivalent to {'a': 1} like in JavaScript. Instead, the key is the value of the variable a.

In this case, a is 1 and b is 2, so {a: 1, b: 2} is just {1: 1, 2: 2}. As a result, you're not actually passing arguments named "a" and "b", and the call.argument methods in Java are returning null.


--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/932a736a-36d0-48cd-9723-ce614d877ea6%40googlegroups.com.

Spandan Bhandari

unread,
Sep 24, 2019, 3:07:07 AM9/24/19
to Flutter Development (flutter-dev)
Thanks Solved :)


On Monday, September 23, 2019 at 9:33:48 AM UTC+5:45, Ryan Gonzalez wrote:
The map of arguments you're passing is:

<int, int>{
 a: 1,
 b: 2,
}

However, Dart isn't JS: keys in maps aren't automatically quoted. By this, I mean {a: 1} is not equivalent to {'a': 1} like in JavaScript. Instead, the key is the value of the variable a.

In this case, a is 1 and b is 2, so {a: 1, b: 2} is just {1: 1, 2: 2}. As a result, you're not actually passing arguments named "a" and "b", and the call.argument methods in Java are returning null.


On Sun, Sep 22, 2019, 3:52 AM Spandan Bhandari <spanndanb...@gmail.com> wrote:



After clicking the button I am getting below exceptions

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages