Skip to content

An open-source cross-platform alternative to AirDrop

feat: migrate away from app_group_directory

Tien Do Nam11e508d5bda1
diff --git a/app/lib/util/native/cache_helper.dart b/app/lib/util/native/cache_helper.dart
index 459c620b..e2f852b7 100644
--- a/app/lib/util/native/cache_helper.dart
+++ b/app/lib/util/native/cache_helper.dart
@@ -3,7 +3,6 @@
import 'dart:io';
import 'dart:isolate';
-import 'package:app_group_directory/app_group_directory.dart';
import 'package:common/util/logger.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/services.dart';
@@ -11,6 +10,7 @@ import 'package:localsend_app/util/file_path_helper.dart';
import 'package:localsend_app/util/native/platform_check.dart';
import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart';
+import 'package:path_provider_foundation/path_provider_foundation.dart';
import 'package:refena_flutter/refena_flutter.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';
@@ -46,12 +46,18 @@ Future<void> _clear(RootIsolateToken token) async {
})
: Future.value(),
checkPlatform([TargetPlatform.iOS])
- ? AppGroupDirectory.getAppGroupDirectory('group.org.localsend.localsendApp').then((directory) async {
- if (directory == null) {
+ ? PathProviderFoundation()
+ .getContainerPath(
+ appGroupIdentifier: 'group.org.localsend.localsendApp',
+ )
+ .then((directoryPath) async {
+ if (directoryPath == null) {
_logger.warning('Failed to get app group directory');
return;
}
+ final directory = Directory(directoryPath);
+
// delete contents of the directory (only files, not directories)
await for (final entry in directory.list(recursive: false, followLinks: false)) {
if (entry is File && !entry.path.fileName.startsWith('.')) {
diff --git a/app/pubspec.lock b/app/pubspec.lock
index 7698be13..ff327fe4 100644
--- a/app/pubspec.lock
+++ b/app/pubspec.lock
@@ -46,14 +46,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
- app_group_directory:
- dependency: "direct main"
- description:
- name: app_group_directory
- sha256: ad89800fd55133b46e1f6940ac6b974562f7fb6394c662c0f4422b90167f2416
- url: "https://pub.dev"
- source: hosted
- version: "2.0.0"
archive:
dependency: transitive
description:
@@ -1043,7 +1035,7 @@ packages:
source: hosted
version: "2.2.12"
path_provider_foundation:
- dependency: transitive
+ dependency: "direct main"
description:
name: path_provider_foundation
sha256: f234384a3fdd67f989b4d54a5d73ca2a6c422fa55ae694381ae0f4375cd1ea16
diff --git a/app/pubspec.yaml b/app/pubspec.yaml
index 83ce4563..457ece89 100644
--- a/app/pubspec.yaml
+++ b/app/pubspec.yaml
@@ -10,7 +10,6 @@ environment:
sdk: ">=3.5.0 <4.0.0"
dependencies:
- app_group_directory: 2.0.0
basic_utils: 5.7.0
collection: ^1.17.2 # allow newer versions, so it can compile with newer Flutter versions
common:
@@ -46,6 +45,7 @@ dependencies:
pasteboard: 0.3.0
path: 1.9.0
path_provider: 2.1.4
+ path_provider_foundation: 2.4.0
permission_handler: 11.3.1
pretty_qr_code: 3.3.0
refena_flutter: 2.1.1