fluffychat/lib/utils/fluffy_share.dart
dependabot[bot] 163c3352db
build: (deps): bump share_plus from 10.1.4 to 11.0.0
Bumps [share_plus](https://github.com/fluttercommunity/plus_plugins/tree/main/packages/share_plus) from 10.1.4 to 11.0.0.
- [Release notes](https://github.com/fluttercommunity/plus_plugins/releases)
- [Commits](https://github.com/fluttercommunity/plus_plugins/commits/share_plus-v11.0.0/packages/share_plus)

---
updated-dependencies:
- dependency-name: share_plus
  dependency-version: 11.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-30 08:30:09 +02:00

46 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:share_plus/share_plus.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import '../widgets/matrix.dart';
abstract class FluffyShare {
static Future<void> share(
String text,
BuildContext context, {
bool copyOnly = false,
}) async {
if (PlatformInfos.isMobile && !copyOnly) {
final box = context.findRenderObject() as RenderBox;
await SharePlus.instance.share(
ShareParams(
text: text,
sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size,
),
);
return;
}
await Clipboard.setData(
ClipboardData(text: text),
);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(L10n.of(context).copiedToClipboard)),
);
return;
}
static Future<void> shareInviteLink(BuildContext context) async {
final client = Matrix.of(context).client;
final ownProfile = await client.fetchOwnProfile();
await FluffyShare.share(
L10n.of(context).inviteText(
ownProfile.displayName ?? client.userID!,
'https://matrix.to/#/${client.userID}?client=im.fluffychat',
),
context,
);
}
}