fryette / webview_cookie_manager

MIT License
47 stars 47 forks source link

Failed to save the cookies without "domain" attribute #34

Closed Mol0ko closed 3 years ago

Mol0ko commented 3 years ago

Both platforms throw errors if I try to call setCookies(List<Cookie> cookies) with cookies that has no domain (domain is null). I think it should be fixed since Cookie class has only two required fields - name and value. Others are optional. Am I right? If I am, I think can fix this and make a PR.

How to reproduce:

final cookie = Cookie('cookie_name', 'cookie_value');
await WebviewCookieManager().setCookies([cookie]);

Android exception:

Exception has occurred.
PlatformException (PlatformException(error, Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
    at io.flutter.plugins.webview_cookie_manager.WebviewCookieManagerPlugin.setCookies(WebviewCookieManagerPlugin.java:126)
    at io.flutter.plugins.webview_cookie_manager.WebviewCookieManagerPlugin.onMethodCall(WebviewCookieManagerPlugin.java:178)

iOS exception:

Could not cast value of type 'NSNull' (0x7fff86d7ab38) to 'NSString' (0x7fff86d9fbb0).
Lost connection to device.

Pub package version: 1.0.7

flutter doctor -v

[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.1 20D74 darwin-x64, locale ru-RU)
    • Flutter version 1.22.6 at /Users/nikitakrasavin/Library/flutter
    • Framework revision 9b2d32b605 (4 weeks ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/nikitakrasavin/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio 4.2 Preview.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[!] Android Studio
    • Android Studio at /Applications/Android Studio 4.2 Preview.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0
fryette commented 3 years ago

Hey!

Feel free to create a pull request. Seems you are right.

fryette commented 3 years ago

Thanks for your contribution. Just published a new version. Will close for now. Feel free to reopen if needed.