Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
In the last section, we created a new fetch image method right here, so the purpose of this method
is going to be to make an HTTP request to that outside API, fetch the JSON for one image and then create
a new instance of the image model class out of it.
But clearly, the first thing that we need to do inside of here is make an HTTP request in order to
make a request.
We're going to import a new package into our dart file.
So at the very top up here, I'm going to import a package.
So package Colon called HTP and I want the dart file out of their.
The package is installed into all new flutter projects by default, so we don't have to do any additional
installation, we can just import it directly into our project.
Now, inside of this package, which is maintained by the DART team, we get a ton of different functions
for making HTP requests.
The only function that you and I actually care about is a specific function called get the get function
allows us to, as you might guess, can get HTTP requests.
Let's very quickly look at some documentation around this package just to get a better idea of what's
going on.
OK, so not the documentation which is at GitHub, dotcom start dangling.
So this is the GitHub repository for it.
If you want to, you can visit it on darte leg or pub right here as well.
And we can pull up some of the documentation over here if we want to.
So on the right hand side, you'll find API docs.
We can go there and it will pull up the documentation, so again, ton of functionality tied to this
thing inside of specifically this HTP library right here that is inside of the package.
On the right hand side, you'll see that we get our list of functions.
And so the only function we care about is the function right here.
We use this to make a request to some outside URL so we can call ticket function with some URL and it's
going to make the request.
Now, you'll notice that the return type, which is annotated to the left of the get word right here,
is something called a future.
We'll talk about what that isn't just a moment.
But first, I want to discuss one other little interesting thing about the import statement that we
just wrote.
So we just wrote out an import to grab every single class, every single function, every single property
inside of the package and import it into our current working file.
And as you can see over here, there is a tremendous amount of code not only inside of HTP right here,
but potentially inside of those other libraries of Browsr clients and testing that are part of the package
as well.
So when we write that one import statement, we are adding a ton of code into our project when actually
you and I only care about this one function right here, just the git function.
We don't care about anything else inside this package.
So in order to avoid importing all those additional classes and all those additional functions, we
can make a little change to our import statement.
So up here after the package name, I'm going to write out as or some not as but show get like.
So.
So by putting on a show, get right here.
This means that this tells darte.
Yeah.
We understand HTTP has just like a billion different classes and functions tied to it, but out of all
those we only care about this one git function.
So dump everything else inside there.
We don't care about it.
Just give us this one function.
OK, so that's just going to avoid us importing unnecessary code into our project.
So now that we've got
more time HTP imported into our project and we've got only the get function.
Let's take a quick break.
We'll come back to the next section and make it use that to make an actual request.
So I'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.