简体   繁体   中英

CookieManager function of dio_cookie_manager plugin conflict with flutter_inappwebview Cookiemanager

When I use the CookieManager function of dio_cookie_manager plugin into the page of included flutter_inappwebview plugin, I got the errors:

The argument type 'CookieManager' can't be assigned to the parameter type 'interceptors'

and

'CookieManager' isn't a function.

How can I use both plugins with separate Cookiemanager?

to avoid such conflicts, make sure that you use import '...' as customName .
For example;

import 'package:dio/dio.dart';
import 'package:dio_cookie_manager/cookie_manager.dart' as dioCookieManager;
import 'package:cookie_jar/cookie_jar.dart';

in that case, you can use it like

var dio =  Dio();
  var cookieJar = CookieJar();
  dio.interceptors.add(dioCookieManager.CookieManager(cookieJar));
// ...

so you can avoid conflicts with other packages as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM