I have this code
import "./HTTPMethod.dart";
import '../../DataModel/DataModel.dart';
mixin RouterMixin {
HTTPMethod method;
String scheme;
String path;
String baseURL;
Map<String, dynamic> params;
Map<String, String> headers;
}
class Router with RouterMixin {
HTTPMethod method;
String scheme;
String path;
String baseURL;
Map<String, dynamic> params;
Map<String, String> headers;
Router._(this.method, this.path, this.scheme, this.baseURL, this.params,
this.headers);
// ignore: missing_return
static Router getRouter(method, path,
{scheme = "https://",
baseURL = "xyz.com",
params = const {},
headers = const {
"Accept": "application/json",
"Content-Type": "application/json"
}}) {
var headerValue = Map<String, dynamic>.from(headers);
DataModel.shared.authToken.then((value) {
print("TOKEN: $value");
if (value != null) {
headerValue["Authorization"] = value;
}
final router =
Router._(method, path, scheme, baseURL, params, headerValue);
return router;
}).catchError((error) {
print("ROUTER: ${error.toString()}");
});
}
}
It gives this error
flutter: type '_ImmutableMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'
Even i tried with simple
static Router routerValue(method, path,
{scheme = "https://",
baseURL = "zyx.com",
params = const {},
headers = const {
"Accept": "application/json",
"Content-Type": "application/json"
}}) {
Router router = Router._(method, path, scheme, baseURL, params,
{"Accept": "application/json", "Content-Type": "application/json"});
return router;
}
I gives same error.