Professional Documents
Culture Documents
Chapter 6
Chapter 6
Callbacks: Functions that are called when an operation completes. Commonly used in
Dart, but can lead to callback hell.
Futures: Represents the result of an asynchronous operation. Allows chaining
operations using then() and handling errors with catchError().
Streams: A sequence of asynchronous events. Enables continuous data flow and real-
time updates.
Example using a Future:
Future<int> fetchNumber() {
void main() {
print('Fetching number...');
fetchNumber().then((number) {
print('Number fetched: $number');
}).catchError((error) {
print('Error: $error');
});
}
import 'dart:isolate';