Solving 'The name 'Response' is defined in the libraries' error in Get and Dio integration in flutter
- Aarthi Krishnan
- Jan 30, 2024
- 1 min read
Updated: May 24, 2024

Hey, guy's it' me Aarthi krishnan. This is a bug-fixing blog. I hope this will help you.
FormData Error:
The name 'FormData' is defined in the libraries 'package:dio/src/form_data.dart (via package:dio/dio.dart)' and 'package:get/get_connect/http/src/multipart/form_data.dart'.
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.
MultipartFile Error
The name 'MultipartFile' is defined in the libraries 'package:dio/src/multipart_file.dart (via package:dio/dio.dart)' and 'package:get/get_connect/http/src/multipart/multipart_file.dart'.
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.
Response Error
The name 'Response' is defined in the libraries 'package:dio/src/response.dart (via package:dio/dio.dart)' and 'package:get/get_connect/http/src/response/response.dart'.
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.
When you use Get package and the Dio package in the same project and declare Response, FormData, and MultipartFile you will get this type of error.
Solution:
You have to hide Response, MultipartFile and FormData from get or dio package like below: if you want to use dio as your primary package then for request hide these parts from Get package
// If you want to use dio as your primary package then for request hide these parts from GetX package
import 'package:get/get.dart' hide Response, FormData, MultipartFile;
Or
If you want to use Gitx as your primary package then for request hide these parts from Dio package
import 'package:dio/dio.dart' hide Response, FormData, MultipartFile;
By hiding these requests you will solve the error 'The name 'Response' is defined in the libraries'. That's it guys. I hope this will save you some time. Happy Coding.
Comments