搜索插件、代码仓与 APP 分类

tweet_ui 封面
插件详情v4.0.5

tweet_ui

在 Android 和 iOS 上显示来自 Twitter API JSON 的推文。支持包含 1-4 张照片、视频、GIF、话题标签、提及、符号、链接、引用推文和转发推文的推文。

AndroidiOS
近 30 天下载
156
喜欢数
67
Pub 分数
120

安装插件

flutter pub add tweet_ui

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

tweet_ui 是一个 Flutter 包,可从 JSON 数据渲染 Twitter 推文,支持丰富的媒体内容,包括 1-4 张照片、视频、GIF、话题标签、提及、符号、URL、引用推文和转发。它在 Android 和 iOS 平台上提供干净、原生般的推文显示效果,非常适合集成 Twitter 内容的社交媒体应用或信息流。该包可轻松处理复杂的推文结构,设置简单,确保跨设备的一致性渲染。

适合场景

  • 在应用中显示 Twitter 活动
  • 将 Twitter 内容集成到社交平台
  • 实时渲染丰富的推文媒体
  • 构建新闻或更新仪表板
  • 显示用户生成的推文内容
  • 创建社交媒体小工具

主要特点

  • 支持多张照片的推文
  • 处理视频和GIF
  • 处理话题标签和提及
  • 显示引用推文和转发推文
  • 适用于所有推文类型的响应式布局
  • 对 Android 和 iOS 的内置支持

适合对象

  • 社交媒体应用开发者
  • 内容聚合平台
  • 新闻源集成
  • 带有用户生成推文展示的应用程序
  • 需要原生 Twitter 用户界面组件的开发者

使用建议

  • 需要有效的 Twitter API JSON
  • 仅限推特相关内容
  • 依赖外部API获取数据
  • 可能需要自定义样式以用于品牌标识
  • 不适用于非Twitter推文来源
  • 需要对限流的API响应进行正确处理

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

tweet_ui

Flutter Tweet UI - Flutter package that is inspired by twitter-kit-android. Works on iOS and Android.

Getting Started

To use this package add it to the pubspec.yaml file:

tweet_ui: <latest_version>

import it:

import 'package:tweet_ui/tweet_ui.dart';

If you want to show tweets with videos: check the better_player installation site

Video/GIF Tweets don't work on iOS simulators (video_player ios instructions)

finally, create a TweetView from a JSON:

API V1.1
TweetView.fromTweetV1(
    TweetV1Response.fromRawJson(
        jsonFromTwitterAPI
        // {"created_at": "Mon Nov 12 13:00:38 +0000 2018", "id": 1061967001177018368, ...
    )
);
API V2
TweetView.fromTweetV2(
    TweetV2Response.fromRawJson(
        jsonFromTwitterAPI
        // {"data": ["created_at": "2020-09-18T18:36:15.000Z", "id": "1061967001177018368", ...
        // or
        // {"data": {"created_at": "2020-09-18T18:36:15.000Z", "id": "1061967001177018368", ...
    )
);

or a CompactTweetView,

API V1.1
CompactTweetView.fromTweetV1(
    TweetV1Response.fromRawJson(
        jsonFromTwitterAPI
        // {"created_at": "Mon Nov 12 13:00:38 +0000 2018", "id": 1061967001177018368, ...
    )
);
API V2
CompactTweetView.fromTweetV2(
    TweetV2Response.fromRawJson(
        jsonFromTwitterAPI
        // {"data": ["created_at": "2020-09-18T18:36:15.000Z", "id": "1061967001177018368", ...
        // or
        // {"data": {"created_at": "2020-09-18T18:36:15.000Z", "id": "1061967001177018368", ...
    )
);

or a EmbeddedTweetView.

API V1.1
EmbeddedTweetView.fromTweetV1(
    TweetV1Response.fromRawJson(
        jsonFromTwitterAPI
        // {"created_at": "Mon Nov 12 13:00:38 +0000 2018", "id": 1061967001177018368, ...
    )
  darkMode: true,
)
API V2
EmbeddedTweetView.fromTweetV2(
    TweetV2Response.fromRawJson(
      jsonFromTwitterAPI
      // {"data": ["created_at": "2020-09-18T18:36:15.000Z", "id": "1061967001177018368", ...
      // or
      // {"data": {"created_at": "2020-09-18T18:36:15.000Z", "id": "1061967001177018368", ...
    )
    darkMode: true,
)

There is also a special QuoteTweetView that is embedded in a TweetView or a CompactTweetView or a EmbeddedTweetView. This depends if a Tweet has a quoted_status value in the JSON.

What tweet view should I create?

TweetView and CompactTweetView are more customisable, but EmbeddedTweetView looks more modern. Check the screenshots below.

Twitter API V2 know problems

In current version of twitter API (V2 as of 14.02.2022) it is not possible to get video url in tweet response. See the following links for more info:

All other video fields (like size or duration) are available in the response. This means that videos will not work for now.

Need more information? Check our wiki pages!

Colors & styling

Custom callbacks

Custom date format

Video player options

Example of supported view and media types:

Standard tweet views
Media type TweetView CompactTweetView EmbeddedTweetView
1 photo img img img
2 photos img img img
3 photos img img img
4 photos img img img
video img img img
GIF img img img
Quoted tweet views
Media type TweetView CompactTweetView EmbeddedTweetView
1 photo img img img
2 photos img img img
3 photos img img img
4 photos img img img
video img img img
GIF img img img

Sample tweets use real-life tweet ids but for example purposes, their content was changed.


Thanks for contributing: dasmikko, jamesblasco, tristan-vrt, daver123, ercadev, ivanjpg, escamoteur, ndahlquist, wszeborowskimateusz, robertmrobo

所属分类

依赖

依赖清单 9 项

源码仓库

使用此插件的项目

暂无相关数据。