After i logged in successfully i got access token, and i'm passing that accestoken using SharedPerference to another screen, i am getting values too in my header and data, but it gives me this error
Error:
type 'String' is not a subtype of type 'int' of 'index'
here is my code
var localhostUrlTimeIn="http://10.0.2.2:8000/TimeIn";
timeIn() async {
Dio dio=new Dio();
//dio.options.headers['content-Type'] = 'application/json';
dio.options.headers["authorization"]="token ${getaccesstoken}";
var data={
'username': getname,
};
await dio
.post(localhostUrlTimeIn,data: json.encode(data),
)
.then((onResponse) async {
print(onResponse.data['message']);
}).catchError((onerror){
print(onerror.toString());
//showAlertDialog(context);
});
}
i am calling this method on button click. please help if anyone know how to fix it.