Flutter - Implementing Share Feature using Share_Plus Plugin - Code With BoltUIX

Flutter share_plus is a plugin that provides an easy way to share content from your Flutter app to other apps installed on the device, such as social media, messaging apps, and email. It supports sharing text, files, and URLs, and allows you to customize the sharing dialog.


Usage:

Flutter plugin for sharing content via the platform share UI, using the ACTION_SEND intent on Android and UIActivityViewController on iOS.

..


Code:


import 'package:flutter/material.dart';
import 'package:share_plus/share_plus.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Share Demo'),
        ),
        body: Center(
          child: ElevatedButton(
            onPressed: () {
              Share.share('Check out this awesome app: https://example.com');
            },
            child: Text('Share'),
          ),
        ),
      ),
    );
  }
}

..


Properties:

  • Share class: Provides methods for sharing content to other apps.
  • Share.share() method: Shares the provided content to other apps.
  • Share.shareFiles() method: Shares the provided files to other apps.
  • Share.shareImage() method: Shares the provided image to other apps.
  • Share.shareVideo() method: Shares the provided video to other apps.
  • Share.shareAudio() method: Shares the provided audio to other apps.
  • Share.shareContent() method: Shares the provided content to other apps with custom sharing options.
..
Flutter Plugins,

Continue : 

Flutter QR Code Generator with Share Functionality

Comments