MovaFeed class

Drives a MovaFeedPool through a vertical feed of MovaFeedItems (bilibili/douyin-style "swipe for next video"): the page the viewer is on plays on its own player while its neighbours are already opened and parked on theirs, so a swipe swaps between two live surfaces instead of tearing one down and rebuilding it.

Replaces the original single-player design (one player, repeated MovaFeedPool.bind-equivalent open() calls) — see doc/SPEC.md's feed entry for the black-flash / stale-frame artifacts that forced the change and the on-device memory measurement that made a pool affordable.

Not a Flutter widget — this is plain, testable core logic. The UI layer (MovaFeedPlayer) owns the PageView and the pool's lifetime, calls activate on page settle, and slotFor/peek to render each page.

用一个 MovaFeedPool 驱动纵向 feed 的 MovaFeedItem 列表 (bilibili/抖音式"上滑下一个视频"):观众所在页在自己的播放器上播放,相邻页 早已在各自播放器上打开并停住,因此一次上滑是在两个活着的画面之间交换,而非 推倒一个再重建。

它取代了最初的单播放器设计(一个播放器,反复 open() 切换)——迫使这次改动的 黑屏闪烁/残留旧帧两个瑕疵,以及让播放器池变得可负担的真机内存实测,见 doc/SPEC.md 的 feed 条目。

不是 Flutter widget——这是纯粹、可测试的 core 逻辑。UI 层 (MovaFeedPlayer)持有 PageView 与池的生命周期,在翻页定格时调用 activate,用 slotFor/peek 渲染每一页。

Constructors

MovaFeed({required MovaFeedPool pool, required MovaFeedLoader loader, int prefetchDepth = 1, IMovaFeedPrefetcher? prefetcher})
Creates a MovaFeed.

Properties

activeIndex → int?
The index most recently passed to activate.
no setter
cachedItemCount → int
当前缓存条目数量,供诊断;示例:feed.cachedItemCount。
no setter
hashCode → int
The hash code for this object.
no setterinherited
loader → MovaFeedLoader
Resolves items by index.
final
pendingItemCount → int
当前持有的在途请求数,供诊断;示例:feed.pendingItemCount。
no setter
pool → MovaFeedPool
The player pool this feed drives.
final
prefetchDepth → int
How many items ahead of the active one get their network path warmed.
final
prefetcher → IMovaFeedPrefetcher
Warm-up strategy applied to items within prefetchDepth.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

activate(int index) → Future<void>
Makes index the playing page: narrows the pool's warm window around it, binds and plays its player, and warms its neighbours in the background.
dispose() → void
Clears cached items and drops any in-flight loads; does not dispose pool, which the caller owns.
ensure(int index) → Future<MovaFeedItem?>
Resolves the item at index, caching the result; concurrent calls for the same unresolved index share one loader invocation.
likeStateOf(int index) → ({int count, bool liked})
The local like state for index: (liked: false, count: 0) if the item hasn't resolved yet.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
peek(int index) → MovaFeedItem?
Synchronously returns the cached item at index, or null if it hasn't resolved yet — for rendering a page's chrome without awaiting.
retains(int index) → bool
返回 index 是否属于当前缓存窗口;首次激活前允许按需加载。 示例:if (feed.retains(index)) renderPage(index)。
slotFor(int index) → MovaFeedSlot?
The pool slot bound to index, or null if no player currently holds it (the page fell outside the warm window, e.g. mid-fling).
toggleLike(int index) → ({int count, bool liked})
Flips the local like state for index, persists it into the item cache (so revisiting within the window keeps the toggle), and fires MovaFeedItem.onLikeChanged. A no-op returning (liked: false, count: 0) if the item hasn't resolved yet.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited