Send Parameters To Android Kotlin Code

4 minutes
Share the link to this page
You need to have access to the item to view this lesson.
One-time Fee
List Price:  $139.99
You save:  $40
List Price:  €128.82
You save:  €36.80
List Price:  £109.74
You save:  £31.35
List Price:  CA$191.13
You save:  CA$54.61
List Price:  A$210.68
You save:  A$60.19
List Price:  S$188.83
You save:  S$53.95
List Price:  HK$1,092.95
You save:  HK$312.29
CHF 91.34
List Price:  CHF 127.88
You save:  CHF 36.54
NOK kr1,052.31
List Price:  NOK kr1,473.28
You save:  NOK kr420.96
DKK kr686.58
List Price:  DKK kr961.24
You save:  DKK kr274.66
List Price:  NZ$227.97
You save:  NZ$65.13
List Price:  د.إ514.17
You save:  د.إ146.91
List Price:  ৳16,408.23
You save:  ৳4,688.40
List Price:  ₹11,637.16
You save:  ₹3,325.14
List Price:  RM657.67
You save:  RM187.92
List Price:  ₦206,269.66
You save:  ₦58,938.40
List Price:  ₨38,916.02
You save:  ₨11,119.65
List Price:  ฿5,127.43
You save:  ฿1,465.08
List Price:  ₺4,505.30
You save:  ₺1,287.32
List Price:  B$723.91
You save:  B$206.84
List Price:  R2,571.91
You save:  R734.88
List Price:  Лв252.38
You save:  Лв72.11
List Price:  ₩190,499.14
You save:  ₩54,432.21
List Price:  ₪515.38
You save:  ₪147.26
List Price:  ₱8,140.48
You save:  ₱2,326.02
List Price:  ¥21,963.82
You save:  ¥6,275.82
List Price:  MX$2,336.09
You save:  MX$667.50
List Price:  QR510.10
You save:  QR145.75
List Price:  P1,900.64
You save:  P543.07
List Price:  KSh18,618.67
You save:  KSh5,320
List Price:  E£6,599.78
You save:  E£1,885.78
List Price:  ብር8,037.80
You save:  ብር2,296.67
List Price:  Kz118,908.34
You save:  Kz33,976.24
List Price:  CLP$126,117.11
You save:  CLP$36,036.03
List Price:  CN¥1,014.10
You save:  CN¥289.76
List Price:  RD$8,237.97
You save:  RD$2,353.87
List Price:  DA18,843.53
You save:  DA5,384.25
List Price:  FJ$311.92
You save:  FJ$89.12
List Price:  Q1,086.64
You save:  Q310.49
List Price:  GY$29,266.81
You save:  GY$8,362.54
ISK kr13,793.62
List Price:  ISK kr19,311.62
You save:  ISK kr5,518
List Price:  DH1,395.33
You save:  DH398.69
List Price:  L2,480.56
You save:  L708.78
List Price:  ден7,930.17
You save:  ден2,265.92
List Price:  MOP$1,125.70
You save:  MOP$321.65
List Price:  N$2,570.90
You save:  N$734.59
List Price:  C$5,148.73
You save:  C$1,471.17
List Price:  रु18,603.56
You save:  रु5,315.68
List Price:  S/522.95
You save:  S/149.42
List Price:  K543.64
You save:  K155.33
List Price:  SAR525.05
You save:  SAR150.02
List Price:  ZK3,733.66
You save:  ZK1,066.83
List Price:  L641.14
You save:  L183.19
List Price:  Kč3,187.01
You save:  Kč910.64
List Price:  Ft49,549.41
You save:  Ft14,157.98
SEK kr1,062.40
List Price:  SEK kr1,487.41
You save:  SEK kr425
List Price:  ARS$124,696.09
You save:  ARS$35,630
List Price:  Bs966.60
You save:  Bs276.19
List Price:  COP$540,370.17
You save:  COP$154,402.50
List Price:  ₡71,720.93
You save:  ₡20,493.15
List Price:  L3,457
You save:  L987.78
List Price:  ₲1,052,195.01
You save:  ₲300,648.62
List Price:  $U5,389.29
You save:  $U1,539.90
List Price:  zł547.82
You save:  zł156.53
Already have an account? Log In


Hello, in this video, I am going to show you how to send parameters to your kotlin file in your Android project from flutter. So I've already shown you in the previous video, how to actually call a method from your kotlin code. If you haven't had a look at that feel wreck, I highly recommend that you go through that video first. And this is why resulted in I click this button says hello from the kotlin world and that is return from here to certainly send values is actually pretty darn simple. What you want to do in your dots on it put raw, not equal to string dynamic. So long then here, we just put the actual key so this is the key date.

This is the validate type making dynamic means we could pass in a number we could pass in a string. You could Get it to an integer. So number for example, that's totally up to you. And bombs gonna send you two strings. Just keep it simple wherever you want to do on the cotton side is totally up to you on both Val one hold on and here on the put just put the number one in a string. The only thing we need to do not dodgeball is they send maps the past they don't pass this in as well go to our main activity Cockney.

And inside of here, what we need to do is first of all, we need to actually get the, you know the parameters of the method and that's part of the method call to do that with Val. Arguments equal to method call dot arguments and we just put map Green na is that of you know dynamic in kotlin and we pop into a bracket so this is the format and then we've actually got all of the arguments. Now what we want to do is actually check for a particular argument. So we are going to say Vol. vow one is equal to arguments. And to get one you just do square brackets and then put the name and the name is whatever you specified is the key, key and value.

And now this has a string one in it because those number it is still inside of the screen. Now what we can do is include if there is equal to string one, then we are going to do a result dot success. Yay. Though dot dot success. And I'll get rid of this one. Yeah.

So if we pass in the value one, which we ought to return, yay, if not your return name. So remember, because we are modifying the Android native side, we need to shut the application down and restarted or, you know, read the book, because he will not build the Android side. If we just do a hot reload or a hot we'll start again, it just takes a bit of time. But you're probably not going to be doing a whole heap of no native kotlin or native Java side, you know, code. So if at the end of the world let's say that Okay, so, so, if I click this button, we get Yay. So we get this year and cut it is the one you want to tune in here.

And I just do a hot reload. And I can do a hot reload because this modification was on the dark side and not on the kotlin. side, we should get you get an A, because the if statement only checks for number one equally multiple checks. And you can have multiple parameters as well you just change the key, which remember is this part. Yeah, that's it. That's how you send parameters from the flutter Dart side, all the way to the native kotlin.

Side of your Android project. Not much more to it than that. If you have any questions though, feel free to pop me a message. And as usual, I look forward to seeing you in the next video.

Sign Up


Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.