share_options 1.0.0 copy "share_options: ^1.0.0" to clipboard
share_options: ^1.0.0 copied to clipboard

outdated

A Flutter plugin for retrieving all share options and share texts over any of them.

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Future<List<ShareOption>> shareOptionsFuture;

  void initState() {
    super.initState();
    shareOptionsFuture = ShareOption.getShareOptions;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Share Options ☺️'),
          ),
          body: FutureBuilder<List<ShareOption>>(
              future: shareOptionsFuture,
              builder: (BuildContext context, snapshot) {
                var shareOptions = snapshot.data;
                switch (snapshot.connectionState) {
                  case ConnectionState.done:
                    return ListView.separated(
                      padding: EdgeInsets.symmetric(
                          vertical: MediaQuery.of(context).size.height / 20),
                      itemCount: shareOptions.length,
                      itemBuilder: (BuildContext context, int index) {
                        var shareOption = shareOptions[index];

                        return ListTile(
                          leading: Image.memory(shareOption.icon),
                          onTap: () =>
                              shareOption.share(sharedText: 'hello world'),
                          title: Text(shareOptions[index].name),
                        );
                      },
                      separatorBuilder: (BuildContext context, int index) =>
                          Divider(),
                    );
                    break;

                  default:
                    return CircularProgressIndicator();
                    break;
                }
              })),
    );
  }
}
16
likes
0
pub points
47%
popularity

Publisher

unverified uploader

A Flutter plugin for retrieving all share options and share texts over any of them.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on share_options