So. Okay, so we're we're, back with dad we rolling we're rolling up now we have to restart. I'm. Sorry oh hi. Okay yeah. I've. Gone full pirate, we've. Got a full pirate with - um. So. We're in here now, in. Our dart. Interface. And we would like to have this be stream. Based because. That is more sort of idiomatic, to dart and flutter as opposed, to just holding it you know this or C++, pulling something a value and make more sense but, we. Have streams in dart and flutter and they're great so, we would like to we. Can keep all this that we have I think we just need a new method for. Subscribing. To a stream and then we're gonna have to in our Java land our java code over here we're. Gonna have to find a way to kick. Something. Out rather than just setting a thing here, so that we can grab it when we want it we want to actually kick a value out so we'll need a method. Channel so that we can call a method. In dart, -. So, so, there's actually an. Event channel, class. That, allows, you to hand. A stream like object do darts and then you can do that is that on the guy. That's. Part of the there's like good oh. That's. The job specs. In the Java Doc's no it's, like are we did we just go to another company what happened, what. Did we just do okay so there's there's there's Java involved. You. Know that yes. There. That our tape there we go a name. Channel for Kimmy oh sorry I thought you're looking for the actual diversion no I was not I was looking for this I just clicked on the wrong thing. Interesting. I've never had call to, use this yet, this. Kind of drive so you know we're talking about how that you won't spend that much time developing plug-ins like this cuz normally you know the, flutter team is behind a whole bunch of them and the community makes makes. Even more and this my. My. Embarrassment kind of just drives home point, well. No I guess I just shows, that yeah, even you mean, we're not writing plugins NOSSA dude yeah that is true well. Tell you what why don't we why don't we switch heats again okay and you can why don't you show me how it's done all right okay. Back. On the laptop of coding. Okay. So I, start. With dirt, sure. So. We. Are going to, wait. The star example, that's the app that's example. Okay. Okay. So, we, have a method channel let's also declare, a event. Channel. How. Long have you been working with dart now actually. I. Want. To say like not. Consecutively. But a total of five years Wow, okay, I feel. Less bad for not knowing this now. Since. I've been working, with dart for like six months now. All. Right, okay, so let's call this. What. Kind of a barometer stream. Yeah. Pressures. Stream baby. I. Guess. We're, just so metal is, so, hard yeah okay. And. Now. So. In our initialize, I think we also need to initialize, this oh. Wait. Well, you already initialized it right there yeah. Right, yes. Sorry. Okay so now we, need to have our our. Dart method that returns, a stream so just. We. Want a stream of. Yeah. Don't we using be fine and then. So. Be a kidder. Pressure. Pressure. Values, you, know pressure what do you. Pressure. Stream is okay. So. We have okay so so, we, just we're defining a getter so. That is a little, teeny function that will return a stream of doubles and. The. Function. Of the getter itself, is that, going to be asynchronous or is it going to it's not because. Yeah, sorry I was in. Yeah. No the getter is just returning a stream and the stream will. Write updates, but I mean all they're all our other methods, are racing to write, right. That's why I was initially but then it says that the results, if you, have a sink. The, result has to be a future and we, don't want a future because this the stream is going to be getting, so, we don't a future of a streams you just want this dream. Is. With. The this. Invoking method. Well. So I mean the other calls are asynchronous because you have to pass a message into the. Other side but, we're just gonna return eyes in the event channel itself exposes. A stream yeah. But we're gonna have to pass a message to, Java. To say give me the stream okay. But. Okay. Let's let's start and send, static. Static, analysis, well that is no one went wrong or, you know failing, to get a number that that might work too okay. So then, I. Can. Type weight, event channel. I'm. Paying attention so don't know what's going on I. Know. There's. Receive, broadcast. Yeah. I. Was looking for the word stream that's. My. God yeah, this is gonna read this. Yes code I'm sorry. Okay. It's, the downside to have a fishing having official support for so many editors okay, so straight, we just returned stream so okay perfect, great. And, is that a typed function. Or. Are we getting a stream of dynamic, oh right, so yes. And actually, okay here's here's a thing I think we should have. A stream, variable, and, only, initialize it once cook we don't need like multiple, if multiple. People or if we subscribed to this stream we don't need a separate, Java object, and it says it's a broadcast stream, which can handle multiple listeners, right, okay.
So, Let, us declare. Make. Everything static, great. Okay. And then, we'll. Say. Return. If. Not no, and then we're gonna call. This. Thing. So, if oh wait, when you decide that. Conditions. Is, there a double question mark equals. Dad, is cool, oh you, didn't know that yeah. That's a new. Feature but yeah basically saying like if this is null, do the thing otherwise. Just. So. Now. I will tell you interesting. That. Should work okay. So now we've got all our dart stuff. We. Can't do we want to delve into the dopest, so. That's so, on a Java side we'll have to make. So we have a method, channels on both sides so. We would need event, channels on both sides too right, yes, so. I think. We. All find our way eventually. Yeah. So yeah. Let's. Yeah. Let's let's, Amy you can you should keep going okay all. Right so. In. Here we're going to register, our. Event, channel mm-hmm. Thank. You so, when the register width method, for. Those of you who saw. Us last time we talked about this a little bit this is where the. Register this is called. When. The plug-in is sort of first spun up and so, this is the hey get ready I'm gonna make some calls on you and I want some data from you so this is where it registers, that method channel so. We can receive method channel requests. To run methods and. Alt-enter. Yeah. I'm. Sure there's one of these codes but I don't know I, used. To use visual studio all the time. Event. Sync instrument. There. So. Here, we have our messenger, basically. The same stuff so. And. The, name of the thing that we want. Yeah. Okay. And then. Okay. So then we want to set this. Barometer, plug in as the handler for that so I think there's a set. Something. Handler or like stream handlers. Okay. It's like it's like it's almost just exactly, what I said. And. It's gonna be this. This, now. Wait. A minute so why didn't we do we, do a new here, and said oh it's a static okay. Yeah. We want the, same object, no probably, not a separate one in case I'm, what I'm saying it's like doing 100 oh. I see what you're saying we're gonna want to have independent. I think, no I caught up with you yes you're gonna want to like capture the, weight. That's. Gonna give us two separate instances of the plug-in that's. What I was just asking yeah you know no what I was gonna say is we should capture the, same pull that into a into a local variable and then ya, know you had it right to begin with. Perfect. Okay. I know.
We're Gonna need to not. Only do, we need an interface that we have - oh right yes yes. So stream handler expects, streaming. Service a implements. Oh. Yes. Okay so, now all. Right so to implement stream, handler. We. Must go deeper. We, have on cancel, and on listen and okay. Just like just. Like any other stream when somebody wants to listen this is for you okay okay so. Those. Things. I'm. Happy about that's. The API level that I still have no. It's. The one-line change that I'm just I'm really busy. I'm. Sure there's an alt inch or something for it to be like. For. This I think it's control, I -. All. Right you need. To access put. Your, public. Private things, control. Try, control I and see if that works, boom. Yeah. Good. Job and tells you or Android studio remind. So we're missing the override keyword on the others but. And. The ones from two weeks ago but, okay. Great. Clearly optional. So. That. Is so. Now we need to implement these. We. Are going to. Basically. Win. Stream. That. We have, initialized. Somewhere, where did it go Oh. API. Okay. So, we have our event channel. Okay. So. We, want to tell, it. When. We listen that we can, start. Putting. Readings. Okay, stream. So yeah let's what's the what are the parameters I know on listen. So. It's arguments. That we I guess don't really care about yeah. I think we just. Want that so. That's. What we once we get the sink that we can put stuff in. So. I guess, we need to I. Think. We need to make. An event sink, mm-hm, and this. Is what we are going to be passing back to do, we can wait I thought we got one in the signature the function I'm, sorry Oh on. Listen oh yes okay. It's. Much easier than making one. Okay. So. We. Are going to we, have we. Have our event sink and, we need to. Know, we need to tell it that we have. Wait. Okay hold on on, listen, is calling, what where, is getting called win. So. That gets called when when, we are setting, it up set stream handler. Okay. So you're saying this is this, plugin is now. Listening okay. And. So, now. We're. Saying, so. We need to keep that so we can use it right yes, the events thing. And. So. That's. What we're gonna do right so okay, so, we, have our on listen method means somebody, is listening and they, give us a thing to send them data so we got to put that somewhere, like, we, need like an M event. Sync yeah. Right. Right. Yeah so we're gonna take yeah. Okay so we're going to take this event. Sink that we've got and then make. One so. There. Should be an event same class it's that. Should exist. What. Do we do it's, all done enter. Option. Sorry cuz we're on a Mac option, and enter. There. We go. Okay. Nope that works. All. Right so. We. Have this. And, we want. To. Maybe.
We Leave we need to back up for a second sure so um. When. Back. In our dart code mm-hmm, we've got. This. Is our example mm-hmm. This. So. We're. Saying I would, like to give the broadcast dream mm-hmm. Don't we. Need. So, okay and then in, here, we're going to create, the stream object that we're passing to. Dart. Correct, I thought. We just got one, from. On listen, I'm sorry we're right. I thought, you'd switch back to the dart file I did. So. I know I just want to talk it I have like yeah so moving things so, we've got we're, gonna say on dart we're gonna say give me a stream, from. The, registrar's. The plug-in management, system, that's, gonna go to the java class and say hey somebody wants a stream and it's gonna call on listen, right. Yes. And so. I, guess, my question is when, when unlisted is called, are. We. We're. Putting the. Events. From. Where. Where are the events coming in that's where am i oh sure because that we covered that one at a different any other episode so that would be in on. Sensor, changes your change so. When. On, listen. Comes we're, constructing this, event. Sync and are we just putting this Emily just reading into events, I think so. It's giving us the event sync we. Would hold, it at that point and then use it right add and, then we would use it up here to just dump. Okay. Got. It I think. We'll. Find out. Yeah. I think so and then, you can just take that line and move it up to the, other one to where it says Emily is reading you just just, success, yourself, a double. Aha. Event, values. No. Or yeah that's that's even better now is there any like. Typing. Like we, should probably check that it's not null there, because otherwise if they haven't listened yet we. Will immediately. Yeah. Where. We smart enough to do this with Colin we could just make it a type spin type. Safe call. Null. Save call. So. If we have an event sink use it and then. On cancel. We, could just know out yeah. God. Okay. That's cool let's, see see, for building the. Old build test oh and, yeah, okay so we we're. Gonna see if it compiles then we have to actually in our example app actually. Use this dream otherwise, nothing I'll ever get so. I. Do. Hopefully. It will not crash. Or anything. Okay. So yeah let's that's a good idea just build it once to make sure every yeah so we're not gonna spray now we're not gonna see anything on, the through. The stream because. We haven't hooked it up in our sample app but we're just making sure that you, don't get horrible. Runtime. Errors and crew. Mental changes yes. Because. We didn't write a test so yeah this is our test right now while. That's building let's jump over to our example, so. What. We want to do here. Oh. Oh. Things happen rate. No. Implementation found, furnishes, a brawler. Um. Do. We want to. We've. Run you run this on Android mm-hmm. So we want to this. Seems not related, to the code oh yeah. Let's go okay let's go look at the plugin real quick and just make sure that nothing got mochi. So. Scroll, scroll, down on that. Fish. Lines barometers right. That's, unusual. This. Is going well. I'm. Gonna, I'm. Gonna stash. My changes, and then, just try and run it to make sure that it works yeah make sure that. Would be great if we were actually gonna get rebooted. Sometimes. I just make an extra copy of the project for funsies we. Don't. You just get close another copy, okay, okay, well. That. One's that one's on me. Exciting. Um. Wait. Why is it running now I. Don't. Even. Know. No that's not what I want to do I wanted to clear the console. Where's. Connor can, you clear this console is. It the two-finger click and you can clear. I. Just. Wanted to try. Again, maybe. We can do a full restart to know.
There's Something going on. Yeah. And. By, the way here's our. 1000s. That's there. I. Feel. Like there, must be some typos, initialized. Thermometer. We. Could always close Android studio and, clean the project and reopen it that's. Just to be sure. Wait. Wait here's another thought here's, another thought but. If we check out a git repo and do ad if. That's. True but, I don't know what else I mean we literally ran this like 45, minutes ago you. Didn't you ran the iOS version now I run the entered one soon okay. Confirm. Accident. Terminates. Then. I think you can go into if. You do. No. I mean right here in the terminal I think you can go to uh just. CD example. I think and. Then. Do flutter clean. Which. I think is a command yes, okay yeah and then we can open Android, studio again oh. Yeah, you could do that flutter run we, have a boat - the Android probably. Back. Before I didn't know that, much about fluttering, I was working on the AdMob plugin I had to do it this way because. I had I didn't know any better I had like three editors open, at all times and for, simulators, trying to make sure although a little. Ads show up what they were supposed to do. You're. Killing me Dart. Oh okay. Initialize. Barometer I let. Us. Maybe. I accidentally. Deleted something, when we were and oh it close okay time to. Do, we want to call this yeah we might have to. They're. Yanking us off yeah. Yeah. This were a Looney Tunes cartoon the big hook would be coming for us. Okay. You. Want to like comment out them the. Event channel stuff just see what's had. To minimis likeness iam made a mistake I, feel, like rather. Than that I suspect like I accidentally. Deleted. Something, when, I was typing. Somehow. Selected, something good, let's see here initialized, barometer. Okay. Somebody's, got to put a comment on this and tell us that it's just in another tab it's. Like the parameter, pressure sensor, on, the simulator. A. Little. Bit I feel. So unsafe, developing, not and again. Okay. You. Can't you can't still let go because we have this code on github and, it is possible to go look at what it was before. Today, started. So. That's possible. Yeah. That's what I was saying is pull. Out pull down a little separate repo and if yeah yeah so. You suggested, the exact thing and then I just repeated your idea like two minutes later. Takes. Me a while sometimes. You. Were you were debugging in your head. Okay. So. It is something wait, wait no. What. The heck, this. Is. Great okay, so let, us add. Back to Java oh. Wait. Those. Aren't supposed to have the same name are they. That. Should be pressure stream. That's. What it is I remember. Thinking when you're in dark to look for that and I didn't think to look here, when. We switched over but a must that's over writing yep, so, somewhere, somewhere. In the register there's a giant map I assumed of string to channel good okay. Okay so. Well, uncomment, everything immediate, success, everything is going to work yeah we'll, go bake a cake. Puppies. Will appear -. Boom - will, fly off into the night into the low-pressure.
Okay, Wait what, did we import here. Event. Something. Stream. Hitler. That. Must be stream handler. I. Thought. There was a little more nothing. That I think that needs to be commented, anything. So. I continued, my rampant, backseat coding hey. Clearly. Making. Mistakes, that's, okay. Okay. So. No. Okay. Okay so now lastly. Before. The, the. Hook really pulls, me off stage. With. Let's add a little into our example app. So. This is I. Mean. And so we want. Let. Us how about we just this. Stage you want just throw a stringbuilder on it yeah, just like below everything else just like and a stream builder there's. Something like that okay um. Or. I was just gonna yeah. Okay if, you had a better idea go for it don't let me don't Reese no let's do that so we. Have this column this, is gonna be beautiful somebody, have. Raised. And. Then. Straighten. Builder. And. Then. Dream. Is. What. Did we call everything. Barometer. Dot where, are you going Brahma Dada pressures name. I'm, not seeing where this is defined. Did. You take it commented out in the barometer. Barometers. Here where are we calling Oh capital, drummer Oh. Whoo. Okay. And then when I definitely shouldn't remember. Context. And a sink. Snapshot. I'm. Only know that cuz I've been doing a lot of stuff with streams. Really. Yeah. I wonder if this okay. If, anybody knows how to make that yeah. L. Die yeah. Maybe. One of the commenters said still with us can let us know because I I often. Request features of the IntelliJ plug-in team and they're like yeah we already have that you just don't know the keystream yes, I, do. Okay, so now we are going to. Snap. Shot. So. Probably need to rebuild the whole oh. I. Said. That's not gonna rebuild the Java right. Back. To full Android studio mood. But. There's gonna be a type error don't see what was what. Was the complaining, I guess we'll find out shortly. Oh. Wait. Oh. No. Okay. No I was just thinking no. There we go broadcast. Stream dynamic. Is not some time to extreme double okay, so. Some. I think we need to do a little typing, cuz I. I'm. Wait where's the method where you get this to as broadcast, or receive broadcast, dream job. Yeah. That's where I was no, no in the in the dart in barometer dart I remember. Wondering. If I Oh. So, where's ad can you like command click on receive. Broadcast stream does that have a type parameter. No. It does not okay so do, we need to a do a cast like dot and do a dot map yeah. Mouth would be the thing to do I think okay. So, goodbye. Little, fancy. Thing. Here, if. So. I, guess windows Hall 9. So. We take we're, gonna map our value. Oh. Map.
To Oh, yeah. I think that's the. That's. The bidness. Great. And then we'll just. Okay. Okay. And, now we. Can use, this. Let's. See moment of truth here. Flutter. Victory. We. Rule air pressure. You're. Now ready to use, this app to help you measure we're. Ready for the hot-air balloon oh yeah. Awesome. Okay. Yeah. We're. Directory, get out of here um let's. Talk about everything we just did so we. We. Came in and there's. A desk. Using. A good old objective-c mmm-hmm. Then we attempted. To package. Publish. The package and we. Ran into an error which we are going to look into and get back with you or someone's gonna be like you forgot yes. Someone. Will tell us worried um and. Then. We. Stream. Fi the Java version I think the last step well there's two, uh steps it would be to stream if I the. IOS. Version so. We'd still need to do that which we might I mean we might just go on yak in a couple of weeks but we should hopefully, one, or both of us will have time to finish this up and get it up on I get up and on you know finish state maybe. - can, do that yes she's, good. And then just yeah a little cleanup. Maybe. Actually adding a test. Yeah, we talked about method channels versus event channels which I learned about having. Not known about them cool. All right. I think. If you're still here, yeah you, should win, a prize there you go. Alright. Guys we'll see it a couple weeks hope you enjoyed it.
2018-09-08