赞
踩
这里主要是用了TabController
这个controller
,而不是用的默认的DefaultTabController
,TabBar跟TabBarView必须关联起来,否则会报错。我这个上面的代码改得还有点多,因为还加入了listview,各位看官就暂时凑合着看吧。
源码贴出来
import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:guoding/api/data_utils.dart'; import 'package:guoding/model/topic_head_bean.dart'; import 'package:guoding/resources/my_dimens.dart'; import 'package:guoding/resources/mycolor_resources.dart'; import 'package:guoding/routers/application.dart'; import 'package:guoding/ui/home/top/topic_list_page.dart'; import 'package:guoding/widgets/my_tab_indicator.dart'; class MoreTopicPage extends StatefulWidget { @override State<StatefulWidget> createState() { return MoreTopicPageState(); } } class MoreTopicPageState extends State<MoreTopicPage> with TickerProviderStateMixin { bool hasTopLoad = false; List<TopicHeadLists> mTabs = new List(); TabController _tabController; int _selectedIndex; @override void initState() { super.initState(); _tabController = new TabController(length: mTabs.length, vsync: this); _tabController.addListener(() { setState(() => _selectedIndex = _tabController.index); print("liucheng-> ${_tabController.indexIsChanging}");<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。