パッケージ、リポジトリ、アプリカテゴリを検索

flutter_share のカバー
パッケージ詳細v2.0.0

flutter_share

FlutterアプリからAndroidおよびiOSでメッセージ、リンク、またはファイルを簡単に共有する方法(EnterキーでいくつかのGIFを表示)。

AndroidiOS
30日間ダウンロード
2770
いいね数
306
Pub ポイント
150

パッケージをインストール

flutter pub add flutter_share

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Flutter Share は、Android および iOS アプリからメッセージ、リンク、ファイルをシームレスに共有できる軽量な Flutter パッケージです。ネイティブの共有インテントを統合するための簡単な API を提供し、ユーザーがシステムダイアログを通じてコンテンツを共有できるようにします。このパッケージはテキストとファイルの両方の共有をサポートしており、迅速な共有機能が必要なアプリに最適です。pub add を通じた最小限の設定で、プラットフォーム固有のコードなしにクロスプラットフォームで動作します。ソースコードは GitHub でオープンであり、透明性とコミュニティの貢献を促進しています。

用途

  • ソーシャルメディア内でリンクを共有する
  • テキストスニペットをメッセージアプリに送信する
  • 画像や文書などのファイルをエクスポートする
  • ユーザー生成コンテンツの共有を有効にする
  • アプリのソーシャル機能との統合

主な機能

  • クロスプラットフォーム対応(AndroidおよびiOS)
  • テキストとファイルを共有するためのシンプルな API
  • ネイティブ共有ダイアログ
  • オープンソースでGitHubリポジトリあり
  • 最小構成が必要

適している対象

  • 基本的な共有機能を必要とするアプリ
  • ソーシャルまたはコンテンツ共有アプリ
  • ファイル管理または生産性ツール
  • 簡単な統合を求める開発者
  • シンプルさと信頼性を重視するプロジェクト

注意事項

  • Android および iOS プラットフォームに限定
  • 共有にはユーザーの操作が必要です
  • 高度なカスタマイズオプションはありません
  • ネイティブOS共有メカニズムに依存しています
  • 特定のアプリに直接共有する機能をサポートしていません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Share Plugin

pub package

** This plugin was discontinued after the flutter official one add support to files **

A Flutter plugin for IOS and Android providing a simple way to share a message, link or local files.

Features:

  • Share messages and/or link urls.
  • Share local files.

android         ios

Installation

First, add flutter_share as a dependency in your pubspec.yaml file.

iOS

Add if not exists one row to the ios/podfile after target runner:

...

target 'Runner' do
    use_frameworks!

...
Android

If you pretends to use the file share, you need to configure the file provider, this will give access to the files turning possible to share with other applications.

Add to AndroidManifest.xml:

<application>
...
<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths"/>
</provider>
</application>

Obs: You can change the android:name if you have an extension of file provider.

Add res/xml/provider_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>

If you want to learn more about file provider you can access:

  • https://developer.android.com/reference/android/support/v4/content/FileProvider
Example

Here is an example flutter app displaying the two shares methods. (I'm using documents_picker just to get a local file you don't need to use.)

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

import 'package:flutter/services.dart';
import 'package:flutter_share/flutter_share.dart';
import 'package:documents_picker/documents_picker.dart';

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

class MyApp extends StatelessWidget {
  Future<void> share() async {
    await FlutterShare.share(
      title: 'Example share',
      text: 'Example share text',
      linkUrl: 'https://flutter.dev/',
      chooserTitle: 'Example Chooser Title'
    );
  }

  Future<void> shareFile() async {
    List<dynamic> docs = await DocumentsPicker.pickDocuments;
    if (docs == null || docs.isEmpty) return null;

    await FlutterShare.shareFile(
      title: 'Example share',
      text: 'Example share text',
      filePath: docs[0] as String,
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              FlatButton(
                child: Text('Share text and link'),
                onPressed: share,
              ),
              FlatButton(
                child: Text('Share local file'),
                onPressed: shareFile,
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Feedback welcome and Pull Requests are most welcome!

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト