-4

the token get null the function dio **

 static Future<Response> getData(
      {@required String url, String token, lang = 'ar'}) async {
    dio.options.headers = {
      'lang': lang,
         'Authorization': '$token',
      'Content-Type': 'application/json',
    };



return await dio.get(url);

} pass values

  void GetData()async {
    emit(Loading_Data());
   await DioHelper.getData(url: Home_, token: token,).then((value) {
      homedata = Home.fromjson(value.data);
     

  emit(Success_Data());
}).catchError((onError){print(onError.toString());
emit(EROOR_Data());

    });
  }

function call in main i use bloc

 providers: [
      BlocProvider(
        create: (context) => ShopingCupit()..GetData(),
      ),

why the token get null thanks

1 Answers1

0

Maybe because u didn't pass the token here return await dio.get(url);

try return await dio.get(url, token);

Ya Si
  • 819
  • 7
  • 12