flutter_share_plus 0.0.7 copy "flutter_share_plus: ^0.0.7" to clipboard
flutter_share_plus: ^0.0.7 copied to clipboard

Flutter plugin to share text and images and many more.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_share_plus/flutter_share_plus.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String _platformVersion = 'Unknown';
  static const _channel = MethodChannel("flutter_share_plus");

  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion = await FlutterSharePlus.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  Future<void> share_text(String message) async {
    await _channel
        .invokeMethod('share_text', <String, String>{'message': message});
  }

  Future<void> share_multiline_text(String title, String description) async {
    await _channel.invokeMethod('share_multiline_text',
        <String, String>{'title': title, 'description': description});
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
      body: Container(
        alignment: Alignment.center,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Container(
              margin: EdgeInsets.all(16),
              child: Text(
                "Platform Version: ${_platformVersion}",
                style: TextStyle(fontSize: 20, color: Colors.red),
              ),
            ),
            ElevatedButton(
                onPressed: () {
                  initPlatformState();
                },
                child: Text("Click me to get version")),
            ElevatedButton(
                onPressed: () {
                  share_text("message111");
                },
                child: Text("Click me to share single text")),
            ElevatedButton(
                onPressed: () {
                  share_multiline_text("title111", "description111");
                },
                child: Text("Click me to share multiple text"))
          ],
        ),
      ),
    ));
  }
}
4
likes
140
points
306
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin to share text and images and many more.

Homepage

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_share_plus

Packages that implement flutter_share_plus