Comments (12)
Pseudo:
const baseDartUrl = 'https://dart.dev';
const baseFlutterUrl = 'https://flutter.dev';
void main() async {
final dio = Dio(BaseOptions(baseUrl: baseDartUrl));
final requestWithDart = await dio.get('/');
final requestWithFlutter = await dio.get('$baseFlutterUrl/');
}
from dio.
I have a genetic method that makes requests to a complete url variable. I remember passing the variable to get
and it would append my base url to the url and it would fail.
Also, how do you change the ResponseType
?
from dio.
I have a genetic method that makes requests to a complete url variable. I remember passing the variable to
get
and it would append my base url to the url and it would fail.
Would be good if you could provide a reproducible case.
Also, how do you change the
ResponseType
?
Each request can specify ResponseType
in their Options
.
from dio.
But that option I am proving is a new option, so wouldn't it override the values in my default option I used for constructing the dio instance?
from dio.
But that option I am proving is a new option, so wouldn't it override the values in my default option I used for constructing the dio instance?
Of course Options
overrides BaseOptions
, but it only happens in that request, rather than further requests.
from dio.
But I want that request to carry all the options provided in the base options, only overriding the ones I need to change, not all of them.
from dio.
I'm wondering if you really tried to use Options
. It works just as you want it to. :)
Given the above conversation, I think your usage might be invalid somehow. I cannot provide suggestions unless there is an actual problem with options, and please provide a reproducible example to explain your demand.
from dio.
@AlexV525 I tested and indeed it worked, I think the docs got me confused, the docs say:
Each Dio instance has a base config for all requests made by itself, and we can override the base config with Options when make a single request.
The word "override" implies that all my Base Options are gone. I thought I would have to recreate all the configurations myself, from both options objects.
I would recommend some more details to ba added to this doc, explaining the options objects are merged, where the items defined inside the new options object will override the fields defined inside the base options.
from dio.
Each Dio instance has a base config for all requests made by itself, and we can override the base config with Options when make a single request.
The word "override" implies that all my Base Options are gone. I thought I would have to recreate all the configurations myself, from both options objects.
I'm not sure it implies the idea you've mentioned. No default values were given in the Options
, thus nothing would be override when you are using an empty Options
. https://pub.dev/documentation/dio/latest/dio/Options-class.html
from dio.
I know that's how the code looks like, but reading the docs that's not clear. The internal code could be easily overriding things with nulls.
from dio.
Override means substitute, merge means combine both into one.
from dio.
Yea, I can see that this might be confusing. Feel free to create a PR to update the documentation!
from dio.
Related Issues (20)
- DIo not working while adding extras in requestOptions with path in Dio singleton HOT 3
- Type Casting Error: '_Map<String, dynamic>' is not a Subtype of 'T?' HOT 1
- Issue with API call when android device is connected via wifi. HOT 1
- Uploading with FormData throws a TypeError: type 'List<int>' is not a subtype of type 'Uint8List' of 'value' HOT 6
- Opportunity to improve the json decoding performance HOT 3
- FormData and List of Int not working as expected. HOT 2
- flutter dynamic coockies management HOT 1
- post请求超时无反应 HOT 1
- Error Dio flutter web HOT 1
- upload file send timeout
- Header is out of order HOT 3
- `ResponseType.stream` is not working on web. HOT 1
- [🔔 Dio] sendTimeout cannot be used without a request body to send HOT 2
- `Transformer.isJsonMimeType` throws format exceptions without caught
- onError is not returning any error HOT 3
- Error when uploading image using MultipartFile.fromBytes in version 5.4.3+1 HOT 1
- 为什么dio的fromMap会将MultipartFile自动放入files字段中 HOT 1
- Error: The method 'debugLog' isn't defined for the class 'BrowserHttpClientAdapter'. HOT 1
- Version 5.5.0 brakes the web build HOT 1
- Is it now possible to use DIO / dio_web_adapter with Web/WASM? HOT 37
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dio.