Logo

dev-resources.site

for different kinds of informations.

How to Clear Cookies in Flutter Custom Tabs?

Published at
1/6/2025
Categories
browser
cookie
flutter
mobile
Author
gowthaman_ravichandran_c5
Categories
4 categories in total
browser
open
cookie
open
flutter
open
mobile
open
Author
25 person written this
gowthaman_ravichandran_c5
open
How to Clear Cookies in Flutter Custom Tabs?

I am using the flutter_custom_tabs package to open a URL in my Flutter app. I need to clear the cookies stored in the browser when the custom tabs browser is closed.

I used a native method (Kotlin for Android, swift for iOS) to clear cookies, but it didn’t work as expected. Although the native scripts executed correctly when called from Flutter, the cookies in the custom tabs browser remained uncleared.

Below is the native code I used:

Android:
privatefun clearBrowserCache() {
WebView(this).clearCache(true)
CookieManager.getInstance().removeAllCookies(null)
WebStorage.getInstance().deleteAllData()
}

iOS:
privatefuncclearBrowserCache() {
let dataStore =WKWebsiteDataStore.default()
let dataTypes =WKWebsiteDataStore.allWebsiteDataTypes()
let dateFrom =Date(timeIntervalSince1970: 0)
dataStore.removeData(ofTypes: dataTypes, modifiedSince: dateFrom, completionHandler: {})
}

Is there a way to clear the cookies of the browser opened with flutter_custom_tabs? Or is there any workaround or alternative solution to achieve this functionality?

flutter Article's
30 articles in total
Favicon
Flutter vs React Native in 2025: A Comprehensive Comparison
Favicon
Building a Cross-Platform Food Ordering App with Flutter
Favicon
Deploying Flutter Web Apps using Globe.dev
Favicon
Flutter App, Speech to Text and Text to Speech 🐣
Favicon
Journey to Clean Architecture: Wrestling with a 10k Line Flutter Legacy Codebase
Favicon
Building the 'One of a Kind' Ultimate Mobile App Framework. Seeking exceptional engineers to join the journey.
Favicon
Why Should You Develop a Native Android App Over Flutter?
Favicon
Flutter Development for Low end PCs
Favicon
5 Essential Flutter Widgets Every Developer Should Master
Favicon
Mastering Nested Navigation in Flutter with `go_router` and a Bottom Nav Bar
Favicon
Flutter for Beginners: From Installation to Your First App
Favicon
Building a Beautiful Login Screen in Flutter: A Complete Guide
Favicon
Flutter Design Pattern Bussines Logic Component (BLOC)
Favicon
Movie X: A Developer’s Dive Into Flutter Project Organization
Favicon
Create Different Type of Flavor on Flutter Application
Favicon
Handling PathAccessException in iOS for File Download
Favicon
Full Stack Development (Mern && Flutter)
Favicon
Common mistakes in Flutter article series
Favicon
Design Pattern in Flutter MVVM
Favicon
7 Ways to Refactor Your Flutter Application
Favicon
is there any good article for custom lint rules in flutter?
Favicon
WebRTC vs Agora Video SDK vs ZegoCloud for Video Calling in Flutter: A Comprehensive Comparison
Favicon
Hassle free flutter Development in Hyprland with Neovim
Favicon
How to Build a CRUD Application Using Flutter & Strapi
Favicon
Flutter vs. React Native: Which mobile framework will you choose in 2025?
Favicon
Understanding ShellRoute in go_router: Managing Shared Layouts Effectively
Favicon
From Chaos to Control: The Day I Learned the Magic of Debouncing in Flutter πŸš€
Favicon
custom lint rules in flutter
Favicon
How to Clear Cookies in Flutter Custom Tabs?
Favicon
Flutter

Featured ones: