Recall & Review
beginner
What is the Dio package in Flutter?
Dio is a powerful HTTP client for Flutter that supports advanced features like interceptors, global configuration, FormData, request cancellation, file downloading, and timeout.
Click to reveal answer
intermediate
How do you add headers globally using Dio?
You can add headers globally by setting them in Dio's options: dio.options.headers = {'Authorization': 'Bearer token'}; This applies headers to all requests.
Click to reveal answer
intermediate
What is an interceptor in Dio?
An interceptor lets you run code before a request is sent, after a response is received, or when an error occurs. It helps modify requests or responses globally.
Click to reveal answer
advanced
How can you cancel an ongoing HTTP request with Dio?
You create a CancelToken and pass it to the request. Calling cancelToken.cancel() stops the request before it completes.
Click to reveal answer
intermediate
What is FormData in Dio and when is it used?
FormData is used to send data like files or key-value pairs in POST requests, especially for uploading files or submitting forms.
Click to reveal answer
Which Dio feature allows you to modify requests before they are sent?
✗ Incorrect
Interceptors let you run code before requests or after responses, allowing modification.
How do you globally set a base URL for all Dio requests?
✗ Incorrect
The baseUrl is set via dio.options.baseUrl property.
What does CancelToken do in Dio?
✗ Incorrect
CancelToken allows you to cancel requests before they finish.
Which Dio class helps to upload files in a POST request?
✗ Incorrect
FormData is used to send files and form fields in POST requests.
How can you handle errors globally in Dio?
✗ Incorrect
Interceptors have an onError callback to handle errors globally.
Explain how to use interceptors in Dio to add an authorization token to every request.
Think about modifying request headers before sending.
You got /4 concepts.
Describe the steps to cancel a long-running HTTP request using Dio.
Focus on how to stop a request before it finishes.
You got /3 concepts.