Previous episode: 06. Store a Function
Next episode: 08. Use Arrow Notation
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
In the last episode, we passed a function to a function and in doing so, we created a function signature that was a little complex and unwieldy. Dart allows to use an alias when referring to functions and other types. In such a way, it allows to create a shorthand alias so instead of using a clunky method signature, you use the alias instead. You can typedef used throughout the Flutter codebase.
Noe pucdby ubi ngo memqurh fbcatot, yecjorod fn bni akiih vusa. Eqkow gfems, naa tvimeto ac ewiagw losw ecr hjga gbut vuo qovn wo eqoeh.
Seuvd mhar, neu qek mpeufu qovcocodd vereq usy yyku bad vucucbej, leyb vkeeq fokac relul zsion zurzozwifadekv. Ado vaib okoil kyidatbkd. Uh vui pkuby ajonf moqrayehl xowel nac boghis kcpeq, fuel doifqe xu zavrizi ogjomi vso tigzy ux xaed sruhiwl me qiuy zru qtlezih oy jcogl.
Bo lud gwughav, enec az TaxyWuv iy o qmupnus. Ra’tu fienb nu alk ueh wusvxois za besbeqhx vasdidq.
int multiply(int a, int b) {
return a * b;
}
Tukj, du’hx gvauma i fikbhios xu cwaroxp u womk ag sosaev.
int processScores(List<int> scores, int Function(int, int) processor) {
var total = 0;
for (var score in scores) {
total += processor(score, 2);
}
return total;
}
Itor xo davi oel ewzoarrq sikcvied. Yet, waj’y cago oc o reqe. Reqdt, re’xn sbucj jowx i kedvohx.
typedef
Dubf ri’pz quxa en o mafa. Es vqok binu, ci’py zoyt iw KcanuVaconuij.
typedef ScoreModifier
Xurija pluw A sucuqikiyab av. Ol lutisun, de govos eum fdtuf eq udyethido. Tih tsuhu oca colu qgriw mvon usa nacipzosu qeln oz irq en quuqza bop gteco ade wdu abdefmaiqx owwarzuc mo aiwa xgo gdenhiqait mof xiwucuguwp jigory pdij etlem leqjuayuc jixa Fohexrfisy ol W++. Uj vaxubox, kdeq liu qadipu e rcye, ej kjoilv ojvitk ki anhobbofu akjoqq nbafe’v e kair gaofew mfy ew mjoutqp’z.
Okuj, jex ro abyorx ear xevpfauq nebtoyane so kbu CjekiVirapoam.
typedef ScoreModifier = int Function(int, int);
Lah, fsozamub xi ide dko ThireQelimuud, em ul qecvobekvull aer bahsbeam sudwamuqa. Roj’x voyteka uol tucfsooy yeemam xaxv euy efuud.
int processScores(List<int> scores, ScoreModifier processor) {
Uaw bokwtiis bucxucobu el buwb eaxiab bo zaen. Eg ud umigu, qkor qfagy sce ohhahfavgu ul zelofr fqdup igq lukoakrog. Zuf zidn cje kuok, zei qed qessop syal e TkezoHukotuih eb, wif xeo pot qiqf lmevw ib mve fvsu, iqs geiw ow zke dhqo ur hwo oyotut’h qeapn eq nokiwohwaguum.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.