title: how to pass access token in header using dio in flutter
body: <p>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</p>
  <p><strong>Error:</strong>
  <code>type 'String' is not a subtype of type 'int' of 'index'</code></p>
  <p>here is my code</p>
  <pre><code>var localhostUrlTimeIn=&quot;http://10.0.2.2:8000/TimeIn&quot;;
    timeIn() async {
  
      Dio dio=new Dio();
      //dio.options.headers['content-Type'] = 'application/json';
      dio.options.headers[&quot;authorization&quot;]=&quot;token ${getaccesstoken}&quot;;
      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);
      });
  
      
    }
  
  </code></pre>
  <p>i am calling this method on button click. please help if anyone know how to fix it.</p>