An API call is a request made by a mobile app to a server to get or send data. It helps the app communicate with remote services.
Click to reveal answer
beginner
Why do mobile apps fetch data from remote servers instead of storing everything locally?
Because remote servers can store large, updated data that many users share. Fetching data remotely keeps the app light and up-to-date.
Click to reveal answer
beginner
What does 'fetching remote data' mean in simple terms?
It means the app asks a server somewhere else on the internet for information it needs, like weather or messages.
Click to reveal answer
intermediate
How does an API call improve user experience in a mobile app?
It provides fresh and personalized data quickly without needing to update the app itself, making the app feel responsive and useful.
Click to reveal answer
beginner
What is a common format for data returned by API calls?
JSON (JavaScript Object Notation) is a common, easy-to-read format used to send data between servers and apps.
Click to reveal answer
Why do mobile apps use API calls to fetch data?
ATo avoid internet usage
BTo increase the app size
CTo get updated information from remote servers
DTo store data only on the device
✗ Incorrect
API calls let apps get fresh data from servers, keeping information current.
What does an API call usually return?
AA physical device
BUser interface elements
CA new app version
DData in formats like JSON
✗ Incorrect
API calls return data, often in JSON format, for the app to use.
Which of these is NOT a reason to fetch data remotely?
ATo make the app work offline only
BTo share data among many users
CTo reduce app storage needs
DTo keep app data updated
✗ Incorrect
Fetching remote data requires internet, so it doesn't support offline-only use.
What is a simple way to describe an API?
AA set of rules for apps to talk to servers
BA programming language
CA type of mobile phone
DA storage device
✗ Incorrect
An API defines how apps and servers communicate.
How does fetching data remotely help keep an app light?
ABy storing all data inside the app
BBy downloading data only when needed
CBy increasing the app's size
DBy avoiding internet connection
✗ Incorrect
Fetching data on demand means the app doesn't carry all data inside, keeping it smaller.
Explain why mobile apps use API calls to fetch remote data instead of storing all data locally.
Think about how apps stay current and share info with many users.
You got /4 concepts.
Describe what happens during an API call in a mobile app.
Imagine the app asking a server for information and getting an answer back.
You got /4 concepts.
Practice
(1/5)
1. Why do Flutter apps make API calls to fetch remote data?
easy
A. To speed up the app without network
B. To store data only on the device
C. To avoid using the internet
D. To get the latest information from the internet
Solution
Step 1: Understand the purpose of API calls
API calls connect to servers to get fresh data, like weather or news updates.
Step 2: Compare options
Only To get the latest information from the internet explains fetching latest info from the internet, others are incorrect.
Final Answer:
To get the latest information from the internet -> Option D
Quick Check:
API calls fetch fresh data = A [OK]
Hint: API calls get fresh data from servers [OK]
Common Mistakes:
Thinking API calls store data locally only
Believing API calls avoid internet use
Confusing API calls with offline storage
2. Which Flutter code snippet correctly starts an API call to fetch data asynchronously?
easy
A. var response = http.get(url);
B. var response = await http.get(Uri.parse(url));
C. var response = http.getSync(Uri.parse(url));
D. var response = http.fetch(url);
Solution
Step 1: Identify correct async syntax
In Flutter, http.get requires Uri and await for async calls.
Step 2: Check each option
var response = await http.get(Uri.parse(url)); uses await and Uri.parse correctly; others are invalid or wrong method names.
Final Answer:
var response = await http.get(Uri.parse(url)); -> Option B
Quick Check:
Async call with await and Uri.parse = A [OK]
Hint: Use await with http.get and Uri.parse for async calls [OK]
Common Mistakes:
Forgetting await keyword
Passing string URL directly without Uri.parse
Using non-existent http.getSync or http.fetch methods
3. What will this Flutter code print if the API returns JSON {"name":"Alice"}?
var response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
var data = jsonDecode(response.body);
print(data['name']);
} else {
print('Error');
}
medium
A. Alice
B. Error
C. null
D. Exception
Solution
Step 1: Check response status
Status code 200 means success, so code enters the if block.
Step 2: Parse JSON and print value
jsonDecode parses JSON string; data['name'] is "Alice", so it prints Alice.
Final Answer:
Alice -> Option A
Quick Check:
Successful API call prints JSON name value = B [OK]
Hint: Status 200 means success; print JSON key value [OK]
Common Mistakes:
Ignoring statusCode check
Not parsing JSON before accessing keys
Expecting 'Error' when status is 200
4. Identify the error in this Flutter API call code:
var response = http.get(Uri.parse(url));
if (response.statusCode == 200) {
print('Success');
}
medium
A. Incorrect statusCode property name
B. Wrong URL format
C. Missing await keyword for async call
D. No error, code is correct
Solution
Step 1: Check async call usage
http.get returns a Future; must use await to get response before accessing statusCode.
Step 2: Identify missing await
Code tries to access statusCode on Future, causing error; await is missing.
Final Answer:
Missing await keyword for async call -> Option C
Quick Check:
Async calls need await before accessing response = C [OK]
Hint: Always await async http.get before using response [OK]
Common Mistakes:
Accessing statusCode on Future without await
Assuming http.get is synchronous
Ignoring async nature of API calls
5. You want your Flutter app to show a list of user names from an API. Which approach correctly fetches and uses the remote data?
A) Call API once, parse JSON list, and update UI with names asynchronously.
B) Store user names locally and never update from API.
C) Call API without checking status code and parse JSON directly.
D) Use synchronous API call to block UI until data loads.
hard
A. Call API once, parse JSON list, and update UI with names asynchronously.
B. Store user names locally and never update from API.
C. Call API without checking status code and parse JSON directly.
D. Use synchronous API call to block UI until data loads.
Solution
Step 1: Understand best practice for API data use
Fetching data asynchronously and updating UI after parsing JSON is correct and user-friendly.
Step 2: Evaluate other options
B ignores fresh data, C risks errors by skipping status check, D blocks UI causing bad experience.
Final Answer:
Call API once, parse JSON list, and update UI with names asynchronously. -> Option A