All language subtitles for 010 Parsing Future Responses into a Model_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

In the last section, we spoke about how our jet function right here returns a future, we get back

a future because we have to wait for that request to be completed before we can actually access the

JSON data, the data that we get back.

So in order to work with the future that comes back, I'm going to use the async 08 syntax to do so.

I'll first mark the inclosing function as being async by putting the async keyword right after my argument

list.

Then in front of the git function, I will write out the await keyword, which tells Darte We need to

wait for the future that gets returned from the get function to be resolved before we can work with

the actual data.

So then after we await that, we're going to take whatever information we got back from the AP and assign

it to a new variable that we will call response.

And claps aside so we can see a little bit.

OK.

Now, one thing I want to point out here is, is that this response variable is not the actual JSON

data.

The response variable is an object that tells us a little bit about the entire response that came back

from that API.

So it contains status codes, headers, a lot of information about the actual request that or the response

that came back from the request that JSON data that we actually care about is nested inside of that

response object.

So now that we've at least got something that contains the Jason day that we care about, we can now

take that, Jason, we can decode it and then we can create a new image model instance from it.

So to get started with that, I'm going to first make sure that I import that image model class that

we created a couple of seconds ago.

Up at the top of the file, I'm going to import and remember, this is an important statement for a

file that you and I wrote, so we don't have to write out the package keyword or the package word here.

We just write out the path to the file that we want to get.

So we're currently inside of Apte Dart.

We're going to go into the models directory and then get the image underscore model, dot, dot, file.

So let's say models slash image.

Oops, image model that darts.

OK, so that works now down here.

Right after we take that response back, we're going to create a new image model instance, so say var

image model equals image model.

We want to take the JSON out of this response object and construct a new image model with it.

So I'm going to call the named constructor from Jason.

And I'm going to pass in that, Jason, from the response object, which is available on response dogsbody.

Now, before we leave it right here, we did miss one step.

Do you know what we missed?

Well, this right here is Jason Data.

It's still that raw, Jason.

So we first have to decode that, Jason, and we decode it by writing out Jason Dot Decode.

And we pass in the response body like so.

OK, now you'll notice that Jason is red right here, says Undefined, named Jason, that is because

we have not imported the package from the dark standard library that contains the JSON object.

So at the very top, I'm going to make sure that I also add on an import statement for darte colon convert.

The convert module that's part of the DART Senior Library is where we get that JSON object from.

So we now get back our response.

The actual raw JSON is available on response to body, we decode that, that gives us some pass JSON

and then we use the front JSON named constructor that we created to create a new image model instance.

And that's it.

That's pretty much it.

So we've now got our image model.

We've definitely made some progress.

But you'll notice that we're not really doing anything with image model just yet.

So let's take a quick pause right here and we'll talk about what we're going to now do that we have

this image model sitting around because obviously we want to eventually somehow get it on the screen

of our device.

It's a quick break and we'll see you in just a minute.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.