您的位置:首页 > 汽车 > 时评 > 网站建设自助建站制作_贵阳seo技术_太原seo排名优化公司_小说推广平台有哪些

网站建设自助建站制作_贵阳seo技术_太原seo排名优化公司_小说推广平台有哪些

2025/2/5 14:06:24 来源:https://blog.csdn.net/qq_40745143/article/details/144694482  浏览:    关键词:网站建设自助建站制作_贵阳seo技术_太原seo排名优化公司_小说推广平台有哪些
网站建设自助建站制作_贵阳seo技术_太原seo排名优化公司_小说推广平台有哪些

tabs切换

简单的tabs切换

在这里插入图片描述

// view
Widget _buildTab() {return TDTabBar(controller: controller.tabController,tabs: controller.tabNames.map((e) => TDTab(text: e)).toList(),onTap: (index) => controller.onTapTabItem(index),backgroundColor: Colors.white,showIndicator: true,indicatorColor: const Color(0xffe01e1e),labelColor: const Color(0xffe01e1e),);
}// controller
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class OrderDetailController extends GetxController with GetTickerProviderStateMixin {OrderDetailController();// tab 控制器late TabController tabController;// tab 索引int tabIndex = 0;// tab 名称List<String> tabNames = ['全部', '待付款', '待发货', '待收货', '已完成'];void onTapTabItem(int index) {tabIndex = index;print('tabIndex: $tabIndex');update(["order_detail"]);}@overridevoid onInit() {super.onInit();tabController = TabController(length: tabNames.length, vsync: this);}@overridevoid onClose() {super.onClose();tabController.dispose();}
}

tabs切换和视图同步

// view
Widget _buildView() {return <Widget>[_buildTab(),Expanded(child: TabBarView(controller: controller.tabController,children: const [Center(child: Text('内容1')),Center(child: Text('内容2')),Center(child: Text('内容3')),Center(child: Text('内容4')),Center(child: Text('内容5')),],),),].toColumn();
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com