Reputation: 1852
On working with Files and directory in my Flutter application, i come through asynchronous and synchronous methods such as createSync() and create or list() and listSync() but i can't understand the main difference between them and scenarios where i can use one of two different version of same function.
The flutter document says:-
Most methods in this class occur in synchronous and asynchronous pairs, for example, create and
createSync. Unless you have a specific reason for using the synchronous version of a method, prefer
the asynchronous version to avoid blocking your program.
Upvotes: 4
Views: 3711
Reputation: 365
Just adding to "void"'s answer: head over to `
` TL;DR, just read and run the example codes. Your most confusion will be solved.
Upvotes: 1
Reputation: 14043
Dart and Flutter has great support for Asynchronous Operations
.
Check out the explanation below: It helps.
Key terms:
1)Synchronous operation: A synchronous operation blocks other operations from executing until it completes.
2)synchronous function: A synchronous function only performs synchronous operations.
3)Asynchronous operation: Once initiated, an asynchronous operation allows other operations to execute before it completes.
4)Asynchronous function: An asynchronous function performs at least one asynchronous operation and can also perform synchronous operations.
Why use Asynchrnous operations and functions
?
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.
For more detailed explanation. Try the link below, it leads to the official documentation:
Upvotes: 8