trevorwang / retrofit.dart

retrofit.dart is an dio client generator using source_gen and inspired by Chopper and Retrofit.
https://mings.in/retrofit.dart/
MIT License
1.06k stars 241 forks source link

Adding static http headers #678

Open karthiga812 opened 1 month ago

karthiga812 commented 1 month ago

Describe the bug I'm trying to add static http headers to my API call like in the example. @Headers(<String, dynamic>{ 'Content-Type': 'application/json', 'Custom-Header': 'Your header', }) But I'm getting an error 'Annotation must be either a const variable reference or const constructor invocation.' Can someone help?

Steps to reproduce the behavior: Add static http headers to any API call like below, @GET('/api/endpoint') @Headers(<String, dynamic>{ 'Content-Type': 'application/json', 'Custom-Header': 'Your header', })

Expected behavior The headers must be added to the API request and should get success response.