Commit 136c7e0

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2023-10-12 12:52:24
remove share_plus dependency
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent de721de
Changed files (9)
android/app/src/main/kotlin/com/derdilla/blood_pressure_app/StorageProvider.kt
@@ -42,6 +42,7 @@ class StorageProvider(private var context: Context,
     private fun sharableUriFromPath(path: String): Uri {
         val initialFile = File(path)
         val sharablePath = File(shareFolder, initialFile.name)
+        if (sharablePath.exists()) sharablePath.delete()
         initialFile.copyTo(sharablePath)
         return getUriForFile(context, "com.derdilla.bloodPressureApp.share", sharablePath)
     }
lib/model/export_import.dart
@@ -306,12 +306,6 @@ class Exporter {
         messenger.showSnackBar(SnackBar(content: Text(localizations.success(exportSettings.defaultExportDir))));
       } else {
         PlatformClient.shareFile(path, 'text/csv'); // TODO: set mime type according to data type
-        /*Share.shareXFiles([
-          XFile(
-              path,
-              mimeType: MimeType.csv.type
-          )
-        ]);*/
       }
     } else {
       messenger.showSnackBar(const SnackBar(content: Text('UNSUPPORTED PLATFORM')));
lib/screens/error_reporting.dart
@@ -1,10 +1,8 @@
-import 'dart:io';
-
+import 'package:blood_pressure_app/platform_integration/platform_client.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/services.dart';
 import 'package:package_info_plus/package_info_plus.dart';
 import 'package:path/path.dart';
-import 'package:share_plus/share_plus.dart';
 import 'package:sqflite/sqflite.dart';
 import 'package:url_launcher/url_launcher.dart';
 
@@ -102,10 +100,7 @@ class ErrorScreen extends StatelessWidget {
 
                           assert(dbPath != inMemoryDatabasePath);
                           dbPath = join(dbPath, 'blood_pressure.db');
-                          assert(Platform.isAndroid);
-                          Share.shareXFiles([
-                            XFile(dbPath,)
-                          ]);
+                          PlatformClient.shareFile(dbPath, 'application/vnd.sqlite3'); // TODO: test
                         } catch(e) {
                           scaffoldMessenger.showSnackBar(SnackBar(
                               content: Text('ERR: ${e.toString()}')));
@@ -120,10 +115,7 @@ class ErrorScreen extends StatelessWidget {
 
                           assert(dbPath != inMemoryDatabasePath);
                           dbPath = join(dbPath, 'config.db');
-                          assert(Platform.isAndroid);
-                          Share.shareXFiles([
-                            XFile(dbPath,)
-                          ]);
+                          PlatformClient.shareFile(dbPath, 'application/vnd.sqlite3');
                         } catch(e) {
                           scaffoldMessenger.showSnackBar(SnackBar(
                               content: Text('ERR: ${e.toString()}')));
lib/screens/settings.dart
@@ -6,6 +6,7 @@ import 'package:blood_pressure_app/components/settings_widgets.dart';
 import 'package:blood_pressure_app/model/blood_pressure.dart';
 import 'package:blood_pressure_app/model/iso_lang_names.dart';
 import 'package:blood_pressure_app/model/storage/settings_store.dart';
+import 'package:blood_pressure_app/platform_integration/platform_client.dart';
 import 'package:blood_pressure_app/screens/subsettings/delete_data.dart';
 import 'package:blood_pressure_app/screens/subsettings/enter_timeformat.dart';
 import 'package:blood_pressure_app/screens/subsettings/export_import_screen.dart';
@@ -20,7 +21,6 @@ import 'package:package_info_plus/package_info_plus.dart';
 import 'package:path/path.dart';
 import 'package:provider/provider.dart';
 import 'package:restart_app/restart_app.dart';
-import 'package:share_plus/share_plus.dart';
 import 'package:sqflite/sqflite.dart';
 import 'package:url_launcher/url_launcher.dart';
 
@@ -302,9 +302,7 @@ class SettingsPage extends StatelessWidget {
                       assert(dbPath != inMemoryDatabasePath);
                       dbPath = join(dbPath, 'config.db');
                       assert(Platform.isAndroid);
-                      Share.shareXFiles([
-                        XFile(dbPath,)
-                      ]);
+                      PlatformClient.shareFile(dbPath, 'application/vnd.sqlite3');
                     }
                 ),
                 SettingsTile(
macos/Flutter/GeneratedPluginRegistrant.swift
@@ -8,7 +8,6 @@ import Foundation
 import file_saver
 import package_info_plus
 import path_provider_foundation
-import share_plus
 import shared_preferences_foundation
 import sqflite
 import url_launcher_macos
@@ -17,7 +16,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
   FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin"))
   FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
   PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
-  SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
   SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
   SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
   UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
windows/flutter/generated_plugin_registrant.cc
@@ -7,14 +7,11 @@
 #include "generated_plugin_registrant.h"
 
 #include <file_saver/file_saver_plugin.h>
-#include <share_plus/share_plus_windows_plugin_c_api.h>
 #include <url_launcher_windows/url_launcher_windows.h>
 
 void RegisterPlugins(flutter::PluginRegistry* registry) {
   FileSaverPluginRegisterWithRegistrar(
       registry->GetRegistrarForPlugin("FileSaverPlugin"));
-  SharePlusWindowsPluginCApiRegisterWithRegistrar(
-      registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
   UrlLauncherWindowsRegisterWithRegistrar(
       registry->GetRegistrarForPlugin("UrlLauncherWindows"));
 }
windows/flutter/generated_plugins.cmake
@@ -4,7 +4,6 @@
 
 list(APPEND FLUTTER_PLUGIN_LIST
   file_saver
-  share_plus
   url_launcher_windows
 )
 
pubspec.lock
@@ -137,14 +137,6 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "3.1.1"
-  cross_file:
-    dependency: transitive
-    description:
-      name: cross_file
-      sha256: fd832b5384d0d6da4f6df60b854d33accaaeb63aa9e10e736a87381f08dee2cb
-      url: "https://pub.dev"
-    source: hosted
-    version: "0.3.3+5"
   crypto:
     dependency: transitive
     description:
@@ -389,14 +381,6 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "1.9.1"
-  mime:
-    dependency: transitive
-    description:
-      name: mime
-      sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
-      url: "https://pub.dev"
-    source: hosted
-    version: "1.0.4"
   mockito:
     dependency: "direct dev"
     description:
@@ -573,22 +557,6 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "1.2.1"
-  share_plus:
-    dependency: "direct main"
-    description:
-      name: share_plus
-      sha256: "6cec740fa0943a826951223e76218df002804adb588235a8910dc3d6b0654e11"
-      url: "https://pub.dev"
-    source: hosted
-    version: "7.1.0"
-  share_plus_platform_interface:
-    dependency: transitive
-    description:
-      name: share_plus_platform_interface
-      sha256: "357412af4178d8e11d14f41723f80f12caea54cf0d5cd29af9dcdab85d58aea7"
-      url: "https://pub.dev"
-    source: hosted
-    version: "3.3.0"
   shared_preferences:
     dependency: "direct main"
     description:
@@ -818,14 +786,6 @@ packages:
       url: "https://pub.dev"
     source: hosted
     version: "3.0.8"
-  uuid:
-    dependency: transitive
-    description:
-      name: uuid
-      sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313"
-      url: "https://pub.dev"
-    source: hosted
-    version: "3.0.7"
   vector_math:
     dependency: transitive
     description:
pubspec.yaml
@@ -18,7 +18,6 @@ dependencies:
 
   intl: ^0.18.0  # BSD-3-Clause
   fl_chart: ^0.63.0  # MIT
-  share_plus: ^7.0.1  # BSD-3-Clause
   csv: ^5.0.2  # MIT
   url_launcher: ^6.1.11  # BSD-3-Clause
   shared_preferences: ^2.1.1  # BSD-3-Clause