影片直播網站原始碼,flutter 頂部滾動欄頁面
影片直播網站原始碼,flutter 頂部滾動欄頁面
tabPage.dart
import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_trip/dao/travelDao.dart'; import 'package:flutter_trip/model/home/commonModel.dart'; import 'package:flutter_trip/model/travel/travelModel.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter_trip/widget/applicationWebView.dart'; import 'package:flutter_trip/widget/loadingContainer.dart'; const _TRAVEL_URL = ' const PAGE_SIZE = 10; class TabPage extends StatefulWidget { final String travelUrl; final String channelCode; TabPage({Key? key, required this.travelUrl, required this.channelCode}) : super(key: key); @override State<StatefulWidget> createState() { // TODO: implement createState return _TabPageState(); } } class _TabPageState extends State<TabPage> with AutomaticKeepAliveClientMixin { List<TravelItem> travelItem = []; int pageIndex = 0; bool isLoad = true; ScrollController _scrollController = ScrollController(); @override // TODO: implement wantKeepAlive bool get wantKeepAlive => true; @override void initState() { // TODO: implement initState super.initState(); _loadData(); _scrollController.addListener(() { if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) { _loadData(loadMore: true); print(""); } }); } @override Widget build(BuildContext context) { // TODO: implement build return Scaffold( body: LoadingContainer( isLoading: isLoad, cover: true, child: RefreshIndicator( onRefresh: _handleRefresh, child: MediaQuery.removePadding( removeTop: true, context: context, child: new StaggeredGridView.countBuilder( controller: _scrollController, crossAxisCount: 2, itemCount: travelItem.length, itemBuilder: (BuildContext context, int index) => _TraveItem(index: index, item: travelItem[index]), staggeredTileBuilder: (int index) => new StaggeredTile.fit(1), // mainAxisSpacing: 4.0, // crossAxisSpacing: 4.0, ), ), ), ), ); } Future<void> _handleRefresh() async { _loadData(); } _loadData({bool loadMore = false}) { if (loadMore) { pageIndex++; } else { pageIndex = 0; } TravelDao.fetch(widget.travelUrl, widget.channelCode, pageIndex, PAGE_SIZE) .then((value) { setState(() { List<TravelItem> items = _filterItems(value.resultList); if (travelItem.length != 0) { travelItem.addAll(items); } else { travelItem = items; } isLoad = false; }); }).catchError((onError) { print('網路請求出錯 $onError'); }); } List<TravelItem> _filterItems(List<TravelItem>? resultList) { List<TravelItem> items = []; if (resultList != null) { resultList.forEach((element) { if (element.article != null) { items.add(element); } }); } return items; } } class _TraveItem extends StatelessWidget { final int index; final TravelItem item; _TraveItem({Key? key, required this.index, required this.item}) : super(key: key); @override Widget build(BuildContext context) { // TODO: implement build return GestureDetector( onTap: () { if (item.article.urls.length > 0) { // Navigator.push( // context, // MaterialPageRoute( // builder: (context) => ApplicationWebView( // commonModel: CommonModel( // icon: '', // title: '詳情', // url: item.article.urls[0].h5Url, // statusBarColor: 'ffffff', // hideAppBar: false), // ))); } }, child: Card( child: PhysicalModel( color: Colors.transparent, clipBehavior: Clip.antiAlias, borderRadius: BorderRadius.circular(5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ _itemImage(), Container( padding: EdgeInsets.all(4), child: Text( item.article.articleTitle, textAlign: TextAlign.left, maxLines: 2, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 14, color: Colors.black), ), ), _infoText(), ], ), ), ), ); } _itemImage() { return Stack( children: [ Image.network(item.article.images[0].dynamicUrl), Positioned( bottom: 8, left: 8, child: Container( padding: EdgeInsets.fromLTRB(5, 1, 5, 1), decoration: BoxDecoration( color: Colors.black54, borderRadius: BorderRadius.circular(10), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( Icons.location_on_outlined, size: 12, color: Colors.white, ), LimitedBox( maxWidth: 130, child: Text( _positonName(), maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 12, color: Colors.white), ), ) ], ), ), ) ], ); } String _positonName() { // return item.article.pois?.length == 0 // ? '未知' // : item.article.pois![0]!.poiName; return item.article.pois?.length == 0 ? '未知' : item.article.pois![0]?.poiName ?? '未知'; } _infoText() { return Container( padding: EdgeInsets.fromLTRB(6, 0, 6, 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ PhysicalModel( color: Colors.transparent, clipBehavior: Clip.antiAlias, borderRadius: BorderRadius.circular(12), child: Image.network( item.article.author!.coverImage!.dynamicUrl, width: 24, height: 24, ), ), Container( width: 90, padding: EdgeInsets.all(5), child: Text( item.article.author!.nickName, textAlign: TextAlign.left, style: TextStyle(fontSize: 12), maxLines: 1, overflow: TextOverflow.ellipsis, ), ) ], ), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Icon( Icons.thumb_up, color: Colors.grey, size: 12, ), Container( padding: EdgeInsets.only(left: 3), child: Text( item.article.likeCount.toString(), maxLines: 1, style: TextStyle( color: Colors.grey, fontSize: 10, ), ), ) ], ) ], ), ); } }
tabTravel.dart
import 'package:flutter/material.dart'; import 'package:flutter_trip/dao/travelDao.dart'; import 'package:flutter_trip/dao/travelTabDao.dart'; import 'package:flutter_trip/model/travel/travelModel.dart'; import 'package:flutter_trip/model/travel/travelTabModel.dart'; import 'package:flutter_trip/pages/travel/tabPage.dart'; class TabTravel extends StatefulWidget { @override _TabTravelState createState() => _TabTravelState(); } class _TabTravelState extends State<TabTravel> with SingleTickerProviderStateMixin { late TabController tabController; late TravelTabModel travelTabModel; bool isInit = false; List<TravelTab> tabs = []; @override void initState() { //tabController = TabController(length: 0, vsync: this); // TODO: implement initState super.initState(); TravelTabDao.fetch().then((TravelTabModel tabModel) { tabController = TabController(length: tabModel.tabs.length, vsync: this); setState(() { tabs = tabModel.tabs; travelTabModel = tabModel; }); this.isInit = true; }).catchError((error) { print("error $error"); }); } @override Widget build(BuildContext context) { // TODO: implement build return Scaffold( body: Column( children: [ isInit ? Container( color: Colors.white, padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top), child: TabBar( padding: EdgeInsets.zero, controller: tabController, isScrollable: true, labelColor: Colors.black87, labelPadding: EdgeInsets.only(left: 20, right: 20), indicator: UnderlineTabIndicator( borderSide: BorderSide( color: Colors.lightBlue, width: 3, ), insets: EdgeInsets.only(bottom: 10), ), tabs: tabs.map((item) => Tab(text: item.labelName)).toList(), ), ) : Container(), Flexible( child: isInit ? TabBarView( controller: tabController, children: tabs .map((item) => TabPage( travelUrl: travelTabModel.url, channelCode: item.groupChannelCode)) .toList(), // children: tabs // .map((item) => Tab(text: item.groupChannelCode)) // .toList(), ) : Container(), ) ], ), ); } @override void dispose() { // TODO: implement dispose tabController.dispose(); super.dispose(); }
以上就是 影片直播網站原始碼,flutter 頂部滾動欄頁面,更多內容歡迎關注之後的文章
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2938064/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Flutter 頁面滾動吸頂詳解(NestedScrollView)FlutterView
- 直播軟體搭建,vue3 頁面回到頂部(平緩滾動效果)Vue
- 直播app原始碼,根據頁面滾動高亮顯示目錄的側邊欄APP原始碼
- 成品直播原始碼,頂部導航欄部分支援左右滑動原始碼
- Flutter SingleChildScrollView 滾動頁面FlutterView
- 直播app原始碼開源,Android 滾動的公告欄APP原始碼Android
- 部落格園裝飾——(二)滾動到頁面頂部或底部
- 三種方式實現平滑滾動頁面到頂部的功能
- 直播平臺原始碼,vue+vue-fullpage實現整屏滾動頁面原始碼Vue
- 影片直播app原始碼,純css實現橫向滾動APP原始碼CSS
- jQuery 頁面滾動 吸頂 和 吸底jQuery
- 直播原始碼網站,自定製配置頁面佈局和寫法原始碼網站
- 直播app原始碼,標題欄隨頁面滑動之title移動定位效果APP原始碼
- 影片直播app原始碼,vue實現列表自動滾動的方式APP原始碼Vue
- 直播平臺製作,禁止頁面滾動 / 滾動事件穿透事件穿透
- 直播軟體原始碼,實現頁面滾動到可視區顯示動畫效果原始碼動畫
- 從頁面底部回到頂部+動畫效果 & 翻頁後從按鈕處回到頁面頂部動畫
- 短影片app原始碼,Flutter元件--搜尋頁面佈局APP原始碼Flutter元件
- 直播app原始碼,跳轉站外連結或平臺內部跳轉頁面APP原始碼
- 線上直播原始碼,JS動態效果之,側邊欄滾動固定效果原始碼JS
- 直播原始碼網站,新使用者登入時的註冊頁面和登入頁面原始碼網站
- 影片直播系統原始碼,flutter Wrap 自動換行元件原始碼Flutter元件
- 好看的404頁面html原始碼 網站404原始碼分享HTML原始碼網站
- 直播商城原始碼,vue 彈窗 慣性滾動 加速滾動原始碼Vue
- 直播網站原始碼,寫一個android底部導航欄框架網站原始碼Android框架
- 【介面設計建議】向下滾動頁面時,建議頂部選單仍然停留在頁面頂部,方便使用者來回切換
- 視訊直播系統原始碼,頂部標題欄的隱藏和標題修改原始碼
- 直播帶貨原始碼,vue中點選按鈕平滑滾動到頁面某個div位置原始碼Vue
- div有滾動條 返回頂部
- 成品直播原始碼推薦,TableView/CollectionView 滑動頂部效果最佳化原始碼View
- app直播原始碼,uniapp之自定義頂部樣式APP原始碼
- 直播平臺原始碼,頂部標籤欄及內容列表的設計與實現原始碼
- 影片直播原始碼,uniapp頁面跳轉的幾種方法和區別原始碼APP
- 滾動到頂部踩坑記錄
- app直播原始碼,利用原生JS實現回到頂部以及吸頂效果APP原始碼JS
- 影片直播原始碼,AndroidStudio登入頁面的切換原始碼Android
- 短視訊直播原始碼,實現頂部導航欄背景圖片漸隱漸現效果原始碼
- 手機直播原始碼,點選按鈕,立即回到頂部原始碼