import 'package:dio/dio.dart'; import 'package:eitc_erm_dental_flutter/global.dart'; //token拦截器 class TokenInterceptor extends Interceptor { @override void onRequest(RequestOptions options, RequestInterceptorHandler handler) { //如果存在token就添加到header里 if (!options.headers.containsKey("token") && hasToken) { options.headers["token"] = token; } handler.next(options); } }