refactor: Migrate to share_plus

This commit is contained in:
Christian Pauly 2022-05-06 08:58:59 +02:00
parent 06a18b2e4e
commit 822b45d885
5 changed files with 6 additions and 21 deletions

View File

@ -7,7 +7,7 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/encryption.dart';
import 'package:matrix/encryption/utils/bootstrap.dart';
import 'package:matrix/matrix.dart';
import 'package:share/share.dart';
import 'package:share_plus/share_plus.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/utils/platform_infos.dart';

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:share/share.dart';
import 'package:share_plus/share_plus.dart';
import 'package:fluffychat/utils/platform_infos.dart';

View File

@ -3,10 +3,9 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:file_picker_cross/file_picker_cross.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
import 'package:path_provider/path_provider.dart';
import 'package:share/share.dart';
import 'package:share_plus/share_plus.dart';
import 'package:fluffychat/utils/platform_infos.dart';
@ -23,17 +22,10 @@ extension MatrixFileExtension on MatrixFile {
void share(BuildContext context) async {
final fileName = name.split('/').last;
final tmpDirectory = PlatformInfos.isAndroid
? (await getExternalStorageDirectories(
type: StorageDirectory.downloads))!
.first
: await getTemporaryDirectory();
final tmpDirectory = await getTemporaryDirectory();
final path = '${tmpDirectory.path}$fileName';
await File(path).writeAsBytes(bytes);
await Share.shareFiles([path]);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context)!.savedFileAs(path))),
);
return;
}

View File

@ -1449,15 +1449,8 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "6.4.0"
share:
dependency: "direct main"
description:
name: share
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
share_plus:
dependency: transitive
dependency: "direct main"
description:
name: share_plus
url: "https://pub.dartlang.org"

View File

@ -75,7 +75,7 @@ dependencies:
salomon_bottom_bar: ^3.2.0
scroll_to_index: ^2.1.1
sentry: ^6.3.0
share: ^2.0.4
share_plus: ^4.0.4
shared_preferences: ^2.0.13
slugify: ^2.0.0
snapping_sheet: ^3.1.0