Live Room Switching | Live Viewing |
![]() |
![]() |
TUILiveKit trial version or activate the paid version.import 'package:atomic_x_core/atomicxcore.dart';import 'package:flutter/material.dart';import 'package:tencent_live_uikit/tencent_live_uikit.dart';class AudienceLiveListPage extends StatefulWidget {const AudienceLiveListPage({super.key, this.liveID = ''});final String liveID;@overrideState<AudienceLiveListPage> createState() => _AudienceLiveListPageState();}class _AudienceLiveListPageState extends State<AudienceLiveListPage> {static const int pageSize = 6;final LiveListViewController liveListController = LiveListViewController();final LiveListStore liveListStore = LiveListStore.shared;bool isLoading = false;int lastAppliedCount = 0;@overridevoid initState() {super.initState();// 1. Fetch the initial live room listrefresh();}Future<void> refresh() async {if (isLoading) return;isLoading = true;final CompletionHandler handler =await liveListStore.fetchLiveList(cursor: '', count: pageSize);isLoading = false;if (!handler.isSuccess) {debugPrint('fetchLiveList failed: ${handler.errorCode}');return;}// 2. Set the list data in fullfinal List<LiveInfo> list = liveListStore.liveState.liveList.value;lastAppliedCount = list.length;liveListController.setData(list);}Future<void> loadMore() async {if (isLoading) return;final String cursor = liveListStore.liveState.liveListCursor.value;if (cursor.isEmpty) return;isLoading = true;final int oldCount = lastAppliedCount;final CompletionHandler handler =await liveListStore.fetchLiveList(cursor: cursor, count: pageSize);isLoading = false;if (!handler.isSuccess) {debugPrint('fetchLiveList failed: ${handler.errorCode}');return;}// 3. Append only the newly fetched page to the end of the listfinal List<LiveInfo> list = liveListStore.liveState.liveList.value;if (list.length > oldCount) {liveListController.appendData(list.sublist(oldCount));lastAppliedCount = list.length;}}@overrideWidget build(BuildContext context) {return Scaffold(backgroundColor: Colors.black,body: LiveListView(controller: liveListController,liveID: widget.liveID,onLoadMore: loadMore,),);}}
import 'package:flutter/material.dart';import 'audience_live_list_page.dart';void enterLiveListPage(BuildContext context, String liveID) {Navigator.of(context).push(MaterialPageRoute<void>(builder: (_) => AudienceLiveListPage(liveID: liveID),fullscreenDialog: true,),);}
Method / Property | Description |
LiveListView({controller, liveID, initialLiveID, onLoadMore}) | Constructor. liveID is used as the first-screen live room; if initialLiveID is also provided, initialLiveID takes precedence. |
onLoadMore | Triggered when the audience swipes to within 2 live rooms from the end of the list; used to load the next page of data. |
LiveListViewController.setData(List list) | Sets the live room list data in full. If not attached, the data is cached. |
LiveListViewController.appendData(List list) | Appends live room data to the end of the list for paginated loading. |
LiveListViewController.isAttached | Indicates whether the controller is already attached to LiveListView. |
Capability | API |
Fetch List | LiveListStore.shared.fetchLiveList(cursor: String, count: int), returns Future |
List Data | LiveListStore.shared.liveState.liveList.value |
Pagination Cursor | LiveListStore.shared.liveState.liveListCursor.value (empty means no more data) |
Feature | Description | Integration Guide |
Audience Viewing | Use PlayerView to watch a single live room, including stream pulling, Enter Room, and interaction features. | |
Host Broadcasting | Complete host broadcasting workflow, including pre-broadcast preparation and post-broadcast interactions. | |
Gift System | Configure custom gift assets, integrate billing, enable PK scenarios, and more. |
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan