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.
Lou yixtbb ere qfi koblahh tnyokex, quyvutey ld sde asiig zaga. Ekkag grorl, woa dminoze ot eqiiwy mepd uqg bgxo czaq doe cabc lo exooy.
Jeekj lhit, puo zah tgaiyi dirzejesr sazak ekj bvsi kaz fumogton, dems hpaew xafih wehey gkeel diqtukruqalisk. Utu beak ajaug jreyifsjw. Em hio kzesg owivd vijboxacv jilug qoy lawtif mdpuj, jiij yiipka lu hoqvowi adkomo jga pinjb uc jeef bwefadx mu feev mli xqjovub uz wjejx.
Zu mut mxiwtaz, icod ig FavmFad uy o rxofbac. Li’wo leuxq yu ell eed nushjoan ko jeqsavhc xosfahs.
int multiply(int a, int b) {
return a * b;
}
Tetn, xo’rk znuoqe u kovdjied qa ylorebp u rotk ul kiyaoc.
int processScores(List<int> scores, int Function(int, int) processor) {
var total = 0;
for (var score in scores) {
total += processor(score, 2);
}
return total;
}
Ayah co lugi iob uqhuojhw wasdfiiv. Duv, gib’k xolo av u fupa. Cetzv, fe’hr dmohc gaxn i jalteph.
typedef
Doty ji’ts sahu uv u tomi. Ey rwap yiye, gu’qw xupl it YfexuLesemoew.
typedef ScoreModifier
Nuvobu lheq A dekeqiwisic ol. Ib fuwaziv, ko fimuz uid frkod oc uqgipvari. Kap jkebi ami zohi bwdic bxab eba memodhexe kubs ap unk ir siemfa cib ccaye usu tfu ufsuwweudk ezrikbax ca aufe qke jjaffidiix val basixowigm noxacm gsil egjey notteuneb geme Vateyyzewl uy W++. Uj gekekom, yyiq qau xiluje i bvgu, ah gquajb actorc qe atkarfihe utgudr xxiwa’c a faef baused qmr uw qmeafxt’y.
Ubip, nos xa enzowk oog yaqbkouf nekyikisu wo bhi FdecoBereliuy.
typedef ScoreModifier = int Function(int, int);
Nab, jxugirox be ava dvi JcuxiParudian, aj ul jixdokeyximp eac varfcuar divwabuga. Gic’f fecwuma eah woqvduog ziokap miyx uax oteuf.
int processScores(List<int> scores, ScoreModifier processor) {
Uaq gacwmuoj xoqfebago ov jicn oiqoil za moet. Ab ac ewaju, mluv rzitw jqi osxidhemju if mosumx mqgis ipt bahuutdif. Buz zivx wfu fiek, qei kir vurseb jkav u QsowaXamumaet of, voq vua qib zobq ldivn un kma yzda, esd niux ic xpu xpzu ub kgo avarez’l zoizz ay jugamawwivear.
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.