Lab 07
Lab 07
Student Name
CMSID
Semester 5th
Lesson Set Building Flutter Applications with
Asynchronous Functionality
7
Purpose 1. Understand the importance of asynchronous programming in Flutter.
2. Learn how to work with Future, async, and await in Flutter.
3. Build a Flutter application that fetches data asynchronously from an API or a
local database.
Procedure 4. Students should read the Pre-lab Reading assignment before coming to the
lab.
5. Students should complete the Pre-lab Writing assignment before entering
the lab.
6. In the lab, students should complete Labs 7.1 through 7.4 in sequence.
Your instructor will give further instructions on grading and completing the
lab.
7. Students should complete the set of lab tasks before the next lab and get
them checked by their lab instructor.
Lab 7
2|Page
PRE-LAB READING ASSIGNMENT
3|Page
}
Fetching Data from APIs: Flutter apps often fetch data from web APIs using
libraries like http or dio. The http package provides a simple way to send
GET, POST, and other requests.
4|Page
try {
await Future.delayed(Duration(seconds: 2));
throw Exception("An error occurred during the operation");
} catch (e) {
print("Error: $e");
}}
5|Page
builder: (context, snapshot) {
if (!snapshot.hasData) {
return CircularProgressIndicator();
}
return Text("Number: ${snapshot.data}");
},); }
6|Page
PRELAB WRITING ASSIGNMENT
4. To handle real-time data in Flutter, you can use a ______, which emits a
sequence of asynchronous events over time.
5. The ______ widget in Flutter listens to a Stream and rebuilds the UI every
time the stream emits a new value.
7|Page
Lab 7.2 Lab Tasks
Note: Make sure to upload the code for each task to a GitHub repository. Do not update or
change the repository after the due date. Provide the link to your GitHub repository with each
task submission.
8|Page