}
}
);
(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.
Dostları ilə paylaş: