Annotation must be either a const variable reference or const constructor invocation

Viewed 1299

i had a error; Annotation must be either a const variable reference or const constructor invocation.dart(invalid_annotation) The name 'Headers' is defined in the libraries 'package:dio/src/headers.dart (via package:dio/dio.dart)' and 'package:retrofit/http.dart'. Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.

I want to pass a jwt token. But i cant pass it through Headers because i get errors

// import 'dart:convert';
// import 'dart:io';
// import 'package:amc_new/model/client_amc.dart';
// import 'package:http/http.dart' as http;
// import 'package:flutter_config/flutter_config.dart';

// String uri = FlutterConfig.get('API_URL');

// class ClientAmcService {
//   // ignore: missing_return
//   Future<ClientAmc> getclientAmc(String amcNo) async {
//     try {
//       var response = await http.get(
//         uri + '/report/getamcreport/$amcNo',
//         headers: {
//           HttpHeaders.authorizationHeader: 'jwt',
//         },
//       );
//       print("------------------------------------------------");
//       if (response.statusCode == 200) {
//         print(response.body);
//         print(response.statusCode);
//         print("------------------------------------------------");
//         List<ClientAmc> clientAmcFromJson(String str) => List<ClientAmc>.from(
//             json.decode(str).map((x) => ClientAmc.fromJson(x)));
//         List<ClientAmc> clientamclist = clientAmcFromJson(response.body);
//         return clientamclist[0];
//       } else {
//         print("Not Found");
//       }
//     } catch (e) {
//       print(e.toString());
//     }
//   }
// }

import 'package:amc_new/model/client_amc.dart';
import 'package:dio/dio.dart';
import 'package:retrofit/http.dart';

part 'amc_client_service.g.dart';

@RestApi()
abstract class ClientAmcService {
  factory ClientAmcService(Dio dio, {String baseUrl}) = _ClientAmcService;

  @GET('/report/getamcreport/{amcNo}')
  @Headers(<String, dynamic>{
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Bearer {jwt}',
  })
  Future<ClientAmc> getclientAmc(@Path('amcNo') String amcNo);
}
1 Answers
Related