Questions: #Q1 What is Flutter?


Q20: Why do we pass functions to widgets?



Yüklə 136,06 Kb.
Pdf görüntüsü
səhifə8/17
tarix07.01.2024
ölçüsü136,06 Kb.
#207354
1   ...   4   5   6   7   8   9   10   11   ...   17
Flutter-Interview-Junior-Middle-Senior-Expert

Q20: Why do we pass functions to widgets?

 

GET START 

 Mid Top 68 Flutter Interview Questions Flutter 68

Answer
Functions are first class objects in Dart and can be passed as parameters to other 
functions.
We pass a function to a widget essentially saying, “invoke this function when some
thing happens”.
Callbacks using interfaces like Android (r a simple callback.
Java Functions are first class objects in Dart and can be passed as parameters to other functions.callback:
button.setOnClickListener(new View.OnClickListener() {
@override
public void onClick(View view) {
// Do something here
}


}
}
);
(Notice that this is only the code for setting up a listener. Defining a button requires separate XML code.)
Dart equivalent:
FlatButton(
onPressed: () {
// Do something here
}
)
(Dart does both declaration as well as setting up the callback.) This becomes much cleaner and organised and
helps us avoid unnecessary complication.
Q21: Explain async, await in Flutter/Dart?

 

GET START 

 Senior Top 68 Flutter Interview Questions Flutter 68

Answer
Asynchronous operations let your program complete work while waiting for another operation to finish. Here are
some common asynchronous operations:
Fetching data over a network.
Writing to a database.
Reading data from a file.
To perform asynchronous operations in Dart, you can use the Future class and the async and await keywords.
The async and await keywords provide a declarative way to define asynchronous functions and use their results.

Yüklə 136,06 Kb.

Dostları ilə paylaş:
1   ...   4   5   6   7   8   9   10   11   ...   17




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin