搜尋套件、儲存庫與 APP 分類

social_embed_webview 封面
套件詳情v0.3.2

social_embed_webview

提供一個 Widget,可輕鬆使用平台的 Web 嵌入功能在 Flutter 中嵌入社群媒體貼文。

AndroidiOS
近 30 天下載
27
喜歡數
43
Pub 分數
120

安裝套件

flutter pub add social_embed_webview

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

social_embed_webview 套件讓 Flutter 開發者能輕鬆在應用程式中嵌入社群媒體貼文,使用平台原生的網頁嵌入功能。它提供一個簡單的元件,透過 WebView 組件直接在應用程式中呈現社交內容(例如推文、Instagram 帖文或 Facebook 更新)。此方法確保與動態社群媒體內容相容,同時在 Android 與 iOS 平台上維持無縫的使用者體驗。此套件非常適合整合社群動態或可分享內容的應用。

適用情境

  • 在新聞應用中嵌入推文
  • 在社交動態中顯示 Instagram 帖子
  • 在社群應用中整合 Facebook 帖子
  • 在內容平台中顯示 YouTube 影片
  • 建立可分享的社群內容預覽

主要特色

  • 用於社群媒體嵌入的簡單小工具
  • 使用平台原生網頁嵌入
  • 支援 Android 和 iOS
  • 輕量且易於整合
  • 處理動態社群媒體內容

適合對象

  • 具有社交媒體整合的應用程式
  • 新聞和內容聚合平台
  • 社交網絡應用
  • 行銷和推廣應用
  • 需要可分享媒體預覽的應用程式

使用建議

  • 依賴互聯網連接
  • 可能需要額外的權限以訪問網頁
  • 性能取決於網路速度
  • 嵌入內容的自定義有限
  • 外部網路內容可能存在的安全考量

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Social Embed WebView (Developers Preview)

Currently non of the major social media platform provides support to embed their post in a flutter app. This flutter package provides widgets to embed posts of various social media platforms using webview_flutter in the background.

Please note

  • version < 0.3.0 is not backward compatiable from this version. So please go through examples before upgrading

Content

Why Us

They are not many solutions in the community to solve this problem. All the packages use the same webview_flutter in the background but have a major issue of a predefined height. While this package adjusts the heights of the webview automatically according to the size of the embedded post.

Supported Platforms:

How to use?

1: Add this to your package's pubspec.yaml file:

dependencies:
  social_embed_webview: 0.3.1

2: You can install packages from the command line:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3: Please visit webview_flutter and follow the steps required for implementations in Android and iOS respectively.

Example

Please make sure to remove <script>...</script> added by the platform with other embed code. Please visit examples for more detailed examples corresponding to each platform

import 'package:flutter/material.dart';
import 'package:social_embed_webview/platforms/twitter.dart';
import 'package:social_embed_webview/social_embed_webview.dart';

/// <srcipts>...</scripts> tag has been removed
String tweetContent = r"""
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Here’s an edit I did of one of my drawings. I tend to draw a lot of aot stuff when each chapter is released. Sorry about that!<br>Song: polnalyubvi кометы<br>Character: Annie Leonhart <a href="https://twitter.com/hashtag/annieleonhart?src=hash&amp;ref_src=twsrc%5Etfw">#annieleonhart</a> <a href="https://twitter.com/hashtag/aot131spoilers?src=hash&amp;ref_src=twsrc%5Etfw">#aot131spoilers</a> <a href="https://twitter.com/hashtag/aot?src=hash&amp;ref_src=twsrc%5Etfw">#aot</a> <a href="https://twitter.com/hashtag/AttackOnTitan131?src=hash&amp;ref_src=twsrc%5Etfw">#AttackOnTitan131</a> <a href="https://twitter.com/hashtag/AttackOnTitans?src=hash&amp;ref_src=twsrc%5Etfw">#AttackOnTitans</a> <a href="https://twitter.com/hashtag/snk?src=hash&amp;ref_src=twsrc%5Etfw">#snk</a> <a href="https://twitter.com/hashtag/snk131?src=hash&amp;ref_src=twsrc%5Etfw">#snk131</a> <a href="https://twitter.com/hashtag/shingekinokyojin?src=hash&amp;ref_src=twsrc%5Etfw">#shingekinokyojin</a> <a href="https://t.co/b4z48ruCoD">pic.twitter.com/b4z48ruCoD</a></p>&mdash; evie (@hazbin_freak22) <a href="https://twitter.com/hazbin_freak22/status/1291884358870142976?ref_src=twsrc%5Etfw">August 7, 2020</a></blockquote> """;

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: SafeArea(
        child: Scaffold(
          appBar: AppBar(
            title: const Text('Social Embed WebView Example'),
          ),
          body: SingleChildScrollView(
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                children: [
                  SocialEmbed(
                      socialMediaObj:
                          TwitterEmbedData(embedHtml: tweetContent)),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Output

Known Bugs

  • Media playback continuous incase of router.push() for all platform
  • Media playback continuous incase of app going in background for all platform except Youtube

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。