feed_player 0.0.1
feed_player: ^0.0.1 copied to clipboard
A reusable Flutter SDK for building and playing a media feed (video-first) with clean architecture and a minimal public API.
feed_player #
Flutter package: video-first feed with autoplay, optional post chrome (likes, comments, …), or TikTok-style full-screen paging.
Add & init #
dependencies:
feed_player: ^0.0.1
import 'package:feed_player/feed_player.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
FeedPlayer.initialize(
const FeedConfig(
baseUrl: 'https://api.example.com',
apiKey: 'YOUR_KEY',
feedEndpointPath: '/v1/feed',
),
);
runApp(const MyApp());
}
FeedPlayer.initialize also boots media_kit (required for playback).
Show the feed #
FeedPlayerWidget(
pageSize: 20,
// Optional: your API → map to FeedItem / FeedMedia (recommended).
// repository: MyFeedRepository(),
)
If you omit repository, the SDK uses the default HTTP repo from FeedConfig.
Layout modes #
| Goal | What to set |
|---|---|
| TikTok / Reels (working) | reelView: true — vertical page snap (one video per swipe), video-only, full height, with optional overlays (right action rail + caption) driven by postChrome + postActions. |
| Social post cards | reelView: false (default) — chrome, postChrome, postActions. |
Optional: onReelViewChanged: (reel) { … } when reelView toggles.
Common knobs (post mode) #
FeedPlayerWidget(
chrome: FeedPlayerChrome.post, // or FeedPlayerChrome.videoOnly
videoViewportHeightFraction: 1 / 3,
itemSpacing: 12,
)
Icons & actions #
- Wire taps with
FeedPostActions(onLikeTap,onCommentTap, …). - Tune visibility with
FeedPostChromeOptionsonpostChrome(showLikeControl,showCommentControl, …). - By default,
hideEngagementWithoutCallbacks: true: no heart/comment/share/etc. unless you set the matching callback. Set it tofalseif you want disabled icons without handlers.
Public API #
Stable exports live in package:feed_player/feed_player.dart (FeedPlayer, FeedPlayerWidget, FeedRepository, FeedItem, chrome/actions types, …). Prefer implementing FeedRepository instead of relying on JSON shape details.
Example #
See example/ for a runnable app (demo repo, reel toggle, comments demo).
Future work #
- Pagination / infinite loading (next-page token)
- Pull-to-refresh
- Better reel prefetching / buffering (next item warm-up)