Flutter Sharing Url (share_plus)
https://pub.dev/packages/share_plus
share_plus | Flutter Package Flutter plugin for sharing content via the platform share UI, using the ACTION_SEND intent on Android and UIActivityViewController on iOS. Flutter plugin for sharing content via the platform share UI, using the ACTION_SEND intent on Android and UIActivityViewController on iOS.
1
2
3
4
5
dependencies:
flutter:
sdk: flutter
share_plus: ^7.2.1 # New Added for share
1
2
// Import for sharing url
import 'package:share_plus/share_plus.dart';
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void _shareSiteUrl(String siteUrl) async {
// Check if the URL is valid
if (await _isUrlValid(Uri.parse(siteUrl))) {
// Share the URL
final result = await Share.shareWithResult(siteUrl);
if (result.status == ShareResultStatus.success) {
printDebug("Share completed successfully");
} else {
printDebug("Share failed with error code ${result.status.toString()}");
}
} else {
// Show an error message if the URL can't be shared
_showSnackbar(
context, "Could not share $siteUrl \n Please check the URL", 1);
}
}
[영상]
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.