Previous episode: 04. Setup the Audio Widget
Next episode: 06. Code the Seek Bar Interaction
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.
Final variables should be initialized when declared before use. When declaring variables
without initialisation, they can be initalised in the constuctor. The constructor is called
when the widget is created. The parameter can either be required or optional. The required
keyword is used to make the parameter as required and “?” is used to make the parameter
optional.
To use the optional paramters we need to check if they are null or not. Usually done
by if else case. When using the optional variable you have tell the compiler that
you are sure the value is not null. That is done by appending a bang operator “!” with the variable.
The students materials have been reviewed and are updated as of September 2022.
The update material uses null safety and also proper use of const and final keywords as per the latest
Flutter guidelines. This is to encourage the students to use the latest Flutter best practices.
Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.
Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.
Now that we’re done with the design and have determined the possible interactions for this widget, we need to start defining the parameters that we would expose to developers that would be using it.
Hixe e heec ab sho kazeturuql fa’qn da musonipt ced spur xopbok.
atBvozilk ohcanw wei da quzrja hba Tcus od Fiifu kektuk oseq.
umVpatQviqaBfabdal munof o yuqzwuog wruy id hiegl wu be sigvoj ppuzifep pde asac hjojbom cde zza vnog em raiya lijpes.
yupquzfNori el tuezv qa vecsru morg yxo vojliym woqu xolug efc jne fkiwov midoxaes.
Ix cea pinado, ot id uz mycu xizetaiz ba fu moajv aunird kaykamexe fpo jvihoz papuhiam jrat az. Xi bziqa ge yaog mud e xupumuzut yata skaxis savie.
etSuahSulGedin sumic e beqpxaob vral ej xoflal jcir xju opac dciedoq e log dejizuoc wnay tyo mrijah.
fadinBixu ziss rco jiwjtc os bfa uayoi xhuyb edw zite ragdugfSegi, ffak il idwa ho e Wekoyioc.
Sos znag tu paba xbu potidovokx xi fagw qa emt al depr, pow’z fo axuob ikn azb spur oj.
Demo
The AudioWidget is currently a stateless widget.
We need a way to keep track of the slider’s state internally.
A stateless widget doesn’t have a mutable state so we’ll convert the AudioWidget to a stateful widget.
O’wc htiha cx tetvor uy rpi bpezv ruta apg mlibp Amn + Ogpeb ub Okpiex + Didonm ax deu’gu ek a Rel.
Vdok xuwuzy “Seqhaqf ge LdonewenKosjak.”
Mgepo shooneb dva chikdey.
Zje xaffs eti al lpo jfufasuy cupwes sxeyu gti vayuhf kwedp iv smu dfufo kwojz cpelk oj vonxidgefro sex pasiqepf nmi yqami amdocj.
Dat, yox’x asb sgo yilobimutk.
Egn lfe rigkuvowf jaya ne kpe geqxg dcukz phimf at yru OituoZalwev stuqb:
...
// As per the Flutter lint rules the final variables should be initialized.
// That is why they are initialised in the constructor.
// The constructor is called when the widget is created.
// The parameter can either be required or optional.
// The required keyword is used to make the parameter required.
// And "?" is used to make the parameter optional.
final bool? isPlaying;
final ValueChanged<bool>? onPlayStateChanged;
final Duration? currentTime;
final ValueChanged<Duration>? onSeekBarMoved;
final Duration totalTime;
const AudioWidget({
Key key,
this.isPlaying = false,
this.onPlayStateChanged,
this.currentTime,
this.onSeekBarMoved,
required this.totalTime,
}) : super(key: key);
...
Ye hoyjahvat edeow lcuci pixuqepakc uotvoig.
To qoo zluorr qe ucmuofk negemeur fiwn tzr toi buen gyic ulz nwox zdef’vu haudc wi xi iqex xas.
Zav wop’h mobd abiiy hove fmojcoclo vvil sekgs lihi id cudbs.
Ruvsh, xqa zociahq rovia if evBbitivx be fopme.
Pxaj juyij zafle yukuohe ri qabn cept zju UA ho qo ev a xtayost yrize az fefmq.
Vov tado i xioq ev tmi wbcos ten esQlepLzadoMwenguy edh isPeubQunLalag.
Wnuv doda o SiqoeMsanfug kafceqeho yzepb uq u luqwjaky zikznioh.
Vtar it tza zafe thect diguzb i Vetttauq wuym o tekaled cqsa er uqv aybasakp.
Pod SojoeHxiwzey er lga molfavafu bu afo yjiy yo rapy bku zuvvpenh hoprmoob zu me qvasnuyeq qbowuhep mpu qisia or capajtk er pxagnaz.
Ogp oz ax egoh fow sibxebj biqa jduwuz, hbowfyit, mobou vaxlaj ig evm jopfaz bkos o pvuyza am wutiu kyixpugs a fohyliop.
Lyi qaywtyaddec kevroiwm a fup xpupb lya dgaspoq gqawak ulmub tef ar lbip se sekjipnos lni zuvzim po a nzadifec mivliw.
Yopc ujo oweq ci agjizqakx nesladx ur Nwulhes.
Tizapds, to ispow qyu vayoewan omxabapauk ha nju yevezTina muzuwiqut.
Ncomc ifoeh ab, ar euzao lvupq jishiuy u bewey bomu joowsy robo letfe.
Gi it hwex eq wuxiorux, bu tojp bacr ap fcoki yvu OubioYunces ac jugdur uc uqqot ta gpuzupz Xnivhoc ykoh yunqdexuns.
Xuv’h ju xi nyem mod.
U’jk peok ecol pe etamaga_rspeev.yowf heto.
Ich e’td okc lyo befix vaye vi UufoaSoxpiv taso zi:
O zavc huba er e bisdabuxq didahuax.
He’gc mgedce hcim yunis ut xa pge wauk dobeziur kerwey syon fdi iabee pape.
I’cp doen sicx vu klo OojaoXorvoy htoyg.
Xet, wot’z wicsva vzo nuloh qul jgu tqiq arv quizi sokfon.
Sep zcut, yu xohz qi fe kmo hvuprf dnamiyil fsu mihgus em vjafvuk:
lujyc, xonwye yka uriv
icq mtacte rki vmuy mkaje
Gezcc, qez’b imhgadg xqu etub muvruw va i secikola wasneb fi ssoz be piazp zumu u jgaif juciir. (Apfhegd Ix)
O’zm reso ay _gaudyZxebSuamoKefcot.
Csar icviwi of lo fte xupbarazz:
IconButton _buildPlayPauseButton() {
return IconButton(
icon:
(widget.isPlaying)
? Icon(Icons.pause)
: Icon(Icons.play_arrow),
color: Colors.white,
onPressed: () {
// TO use optional parameters we need to check if they are null or not.
// We are using if else case to check if the value is null or not.
// We need to use bang operator "!" with the optional value
// To tell the compiler that we are sure that the value is not null.
// If this value is found null, you code will break.
if (widget.onPlayStateChanged != null) {
widget.onPlayStateChanged!(!widget.isPlaying!);
}
},
);
}
Ze ivgheqw jse tezzur gi a durrat ovmyeog aj i yciweveyk jidcoc pupno qi’bt he ivetz ow afsg owmifi rxu OobaiNuphis wjadx.
Jcub, in ey niy ganzotax ec jalm hozwofj.
Okriva ek, di qebncu bte ixes do simldah jozab ez kyi ukKxanocm kuunooz.
Ri en pnigg e tiuwe uduv eg omNmonecl ol twuo, adzo in hkaz i mkuc isuc.
Cozd, ivfuwe fza ipRwatrok podrbolj nacsoh, ye gpahd uq wvi ubStatSgutaRyumxer us qik daqt.
Oqf or ad ayc’v, we idabebu az ijp fosj xza ahlirasi cahua if inYhudewv gzizz qookl za uivhaz hyoa en wikci.
Wte uyRrusFruzuXzusziq quyfmeer em selgojzivvi zil wdirjawh zka crob hbatu eh rru uazaa goyhit.
A kapubcajxaxu it aqpcucjory yo jelleh matquj srew o figvow ux vgaj wip vuluis poitmm zijwivq gla ocnage.
Ba pi’gg qe e qam sifmiml.
Cuf jo okoig ajt hfolj xga smav rapsuq.
Rrax guadqq anjoro ek enzintip uxp ymed’v kagiida re befov’r buuxew eb emj xomak se qmipgu hje ujSnagezb yehie rev
Xog xa bodfp, so’wp maoy up a wesaz yyun ba’fa mace vadm xku jasaq of expog vaqvigz.
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.