Skip to content

Commit

Permalink
v0.7.4: Fixes a few issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrier989 committed Mar 29, 2023
1 parent 27f5d06 commit fe532cb
Show file tree
Hide file tree
Showing 8 changed files with 468 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_foundation-2.1.3/","native_build":true,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/me/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.2.1/","native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_android-2.0.24/","native_build":true,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":true,"dependencies":[]},{"name":"webview_flutter_android","path":"/Users/me/.pub-cache/hosted/pub.dev/webview_flutter_android-3.4.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_foundation-2.1.3/","native_build":true,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.10/","native_build":false,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":false,"dependencies":["url_launcher_linux"]},{"name":"url_launcher_linux","path":"/Users/me/.pub-cache/hosted/pub.dev/url_launcher_linux-3.0.4/","native_build":true,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.5/","native_build":false,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":true,"dependencies":["url_launcher_windows"]},{"name":"url_launcher_windows","path":"/Users/me/.pub-cache/hosted/pub.dev/url_launcher_windows-3.0.5/","native_build":true,"dependencies":[]}],"web":[{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","dependencies":["url_launcher_web"]},{"name":"url_launcher_web","path":"/Users/me/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.16/","dependencies":[]},{"name":"webview_flutter_web","path":"/Users/me/.pub-cache/hosted/pub.dev/webview_flutter_web-0.2.2+1/","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"share_plus","dependencies":["url_launcher_web","url_launcher_windows","url_launcher_linux"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]},{"name":"webview_flutter","dependencies":["webview_flutter_android","webview_flutter_wkwebview"]},{"name":"webview_flutter_android","dependencies":[]},{"name":"webview_flutter_web","dependencies":[]},{"name":"webview_flutter_wkwebview","dependencies":[]}],"date_created":"2023-03-17 01:26:57.731155","version":"3.7.7"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_foundation-2.1.3/","native_build":true,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":true,"dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/me/.pub-cache/hosted/pub.dev/webview_flutter_wkwebview-3.2.1/","native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_android-2.0.24/","native_build":true,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":true,"dependencies":[]},{"name":"webview_flutter_android","path":"/Users/me/.pub-cache/hosted/pub.dev/webview_flutter_android-3.4.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_foundation-2.1.3/","native_build":true,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.10/","native_build":false,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":false,"dependencies":["url_launcher_linux"]},{"name":"url_launcher_linux","path":"/Users/me/.pub-cache/hosted/pub.dev/url_launcher_linux-3.0.4/","native_build":true,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/me/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.5/","native_build":false,"dependencies":[]},{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","native_build":true,"dependencies":["url_launcher_windows"]},{"name":"url_launcher_windows","path":"/Users/me/.pub-cache/hosted/pub.dev/url_launcher_windows-3.0.5/","native_build":true,"dependencies":[]}],"web":[{"name":"share_plus","path":"/Users/me/.pub-cache/hosted/pub.dev/share_plus-6.3.1/","dependencies":["url_launcher_web"]},{"name":"url_launcher_web","path":"/Users/me/.pub-cache/hosted/pub.dev/url_launcher_web-2.0.16/","dependencies":[]},{"name":"webview_flutter_web","path":"/Users/me/.pub-cache/hosted/pub.dev/webview_flutter_web-0.2.2+1/","dependencies":[]}]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"share_plus","dependencies":["url_launcher_web","url_launcher_windows","url_launcher_linux"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]},{"name":"webview_flutter","dependencies":["webview_flutter_android","webview_flutter_wkwebview"]},{"name":"webview_flutter_android","dependencies":[]},{"name":"webview_flutter_web","dependencies":[]},{"name":"webview_flutter_wkwebview","dependencies":[]}],"date_created":"2023-03-29 20:21:40.810622","version":"3.7.8"}
20 changes: 17 additions & 3 deletions .gitignore
Expand Up @@ -22,9 +22,23 @@ migrate_working_dir/
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
build/
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
7 changes: 4 additions & 3 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
## 0.7.4
* Fixes web behavior and improves cookie/cache/localStorage clearing implementation.

## 0.7.3
* Improves documentation

Expand All @@ -9,9 +12,7 @@
* Improves documentation

## 0.7.0
* Allows cookies, caches, and local storage to be cleared with a static method in BrowserController.
By default, they are cleared when the app is started and when more than 24h is the from the last
clearing.
* Allows cookie/cache/localStorage to be cleared with a static method in BrowserController.

## 0.6.1
* Small fixes.
Expand Down
16 changes: 9 additions & 7 deletions README.md
Expand Up @@ -28,7 +28,7 @@ Licensed under the [Apache License 2.0](LICENSE).
In _pubspec.yaml_:
```yaml
dependencies:
web_browser: ^0.7.3
web_browser: ^0.7.4
```

## 2.Display web browser
Expand Down Expand Up @@ -118,21 +118,23 @@ void main() {
```

## Cache clearing
For privacy reasons, the package clears persistent state every now and then. This includes:
For end-users privacy, it is good to clear:
* Cookies
* Caches
* Local storage

You can disable this behavior in your `main` function:
You can enable this by setting:
```dart
import 'package:web_browser/web_browser.dart';
void main() {
// Disables clearing when the app is started
BrowserController.resetGlobalStateAtStart = false;
// Clear when the app is started
BrowserController.resetGlobalStateAtStart = true;
// Disables expiration.
BrowserController.globalStateExpiration = null;
// Clear every now and then.
BrowserController.globalStateExpiration = const Duration(days: 1);
// ...
}
```

Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Expand Up @@ -371,7 +371,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.6.0"
version: "0.7.3"
webview_flutter:
dependency: transitive
description:
Expand Down
13 changes: 9 additions & 4 deletions lib/src/web_browser/browser_controller.dart
Expand Up @@ -24,19 +24,18 @@ import '../../web_browser.dart';
class BrowserController extends ChangeNotifier {
/// How often [BrowserController.clearEverything] should be called.
///
/// If null, the cache is never cleaned. The default is currently 1 day, but
/// we could make it shorter or longer in a future version.
/// If null, the cache is never cleared automatically.
///
/// This is a global variable because the underlying platform APIs don't have
/// good support for per-browser clearing.
///
/// See also [resetGlobalStateAtStart].
static Duration? globalStateExpiration = const Duration(days: 1);
static Duration? globalStateExpiration;
static final _globalStateExpirationStopwatch = Stopwatch()..start();

/// Whether [BrowserController.clearEverything] is called after starting the
/// app.
static bool resetGlobalStateAtStart = true;
static bool resetGlobalStateAtStart = false;

static int _globalStateVersion = 0;
static Future<void>? _stateClearingFuture;
Expand Down Expand Up @@ -312,6 +311,9 @@ class BrowserController extends ChangeNotifier {

/// Checks whether the cache should be cleared.
Future<void> _maybeClearState() async {
if (kIsWeb) {
return;
}
if (_globalStateVersion == 0 && resetGlobalStateAtStart) {
await clearEverything();
} else {
Expand Down Expand Up @@ -347,6 +349,9 @@ class BrowserController extends ChangeNotifier {
/// Clears all persistent state, including cookies, caches, and local
/// storage.
static Future<void> clearEverything() async {
if (kIsWeb) {
return;
}
// Combine multiple calls into one.
return _stateClearingFuture ??= () async {
try {
Expand Down

0 comments on commit fe532cb

Please sign in to comment.