当前位置: 首页 > news >正文

flutter下拉列表

下拉列表

内容和下拉列表的标题均可滑动

Expanded: 内容限制组件,将其子类中的无限扩展的界面限制在一定范围中。在此使用,是为了防止下拉列表中的内容超过了屏幕限制。

SingleChildScrollView: 这个组件,从名字中可以看出来,不必多说,是可以控制的滑动组件,并且是其系统自带的

ExpansionTile: 这个就是系统自带的下拉列表组件,title中展示下拉列表的标题,children[ ] 中展示下拉列表的内容。

 Expanded(child: SingleChildScrollView(	//滑动组件child: ExpansionTile(	title: Text(		//下拉列表的标题"详细信息",style: TextStyle(fontWeight: FontWeight.bold, fontSize: ScreenUtil().setSp(32)),),children: [  //下拉列表中的内容Container(padding: EdgeInsets.only(left: 30, right: 20, bottom: 10),child: _patientinfo()),Container(padding: EdgeInsets.only(left: 30, right: 20, bottom: 10),child: _vitalsign(),),Container(padding: EdgeInsets.only(left: 30, right: 20, bottom: 20),child: _inspect(),),Container(padding: EdgeInsets.only(left: 30, right: 20, bottom: 20),child: _firstaid(),),Container(padding: EdgeInsets.only(left: 30, right: 20, bottom: 20),child: _handovertime(),),Container(padding: EdgeInsets.only(left: 30, right: 20, bottom: 20),child: _remarks(),),],)))

在这里插入图片描述
使用这个三个组件进行嵌套的话,是可以实现下拉列表滑动,但是,其标题也可以滑动了,不满足策划需求。所以又做出了第二种方式。如下所示

内容均可滑动,标题不滑动

为了使下拉列表的标题不动,内容可以进行滑动,系统自带的下拉列表不能满足条件,通过不同的组件组合,实现这个功能。
在此使用了InkWell组件。并且加载了动画,在点击时,动画展开面板,如下图所示。

class PulldownItem extends StatefulWidget {PulldownItem({Key? key}) : super(key: key);State<PulldownItem> createState() => _PulldownItemState();
}class _PulldownItemState extends State<PulldownItem>with SingleTickerProviderStateMixin {late AnimationController _animationController;late Animation<double> _animation;var _crossFadeState = CrossFadeState.showSecond;void initState() {super.initState();_animationController = AnimationController(duration: const Duration(milliseconds: 300), vsync: this);_animation = Tween(begin: .5, end: 0.0).animate(_animationController);}void dispose() {_animationController.dispose();super.dispose();}Widget build(BuildContext context) {return Container(width: double.infinity,margin: EdgeInsets.only(bottom: 30.w),child: Column(children: [InkWell(highlightColor: Colors.transparent,splashColor: Colors.transparent,onTap: () {if (_animationController.status == AnimationStatus.completed) {_animationController.reverse();_crossFadeState = CrossFadeState.showSecond;} else {_animationController.forward();_crossFadeState = CrossFadeState.showFirst;}setState(() {});},child: Padding(padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 30.w),child: Row(children: [Text("widget.title",  //下拉列表的标题style: TextStyle(fontSize: 32.sp,color: Colors.black,fontWeight: FontWeight.bold,height: 1),),const Spacer(),RotationTransition(			//下拉列表右边的小三角形alignment: Alignment.center,turns: _animation,child: Image.asset('assets/login/select_img_ambulance.png',width: 46.w,fit: BoxFit.contain,),),],),),),Expanded(child: AnimatedCrossFade(duration: const Duration(milliseconds: 300),firstChild: Container(width: double.infinity,padding: EdgeInsets.symmetric(horizontal: 32.w),child: SingleChildScrollView(child: Column(children: [		//下拉列表的内容,在此是可以滑动的Text("下拉列表的内容"),],),),),secondChild: const SizedBox(width: double.infinity,),crossFadeState: _crossFadeState,),),],),);}
}
http://www.lryc.cn/news/231772.html

相关文章:

  • ElastaticSearch -- es深度分页 searchAfter
  • 【2021集创赛】Arm杯二等奖-基于Arm核的智慧病房手势识别方案
  • 通过注解统计接口调用耗时
  • Oracle-动态sql学习笔记,由易至难讲解七个例子
  • Kafka 的应用场景
  • 保驾“双十一” 博睿数据助力电商零售迎高峰无烦忧
  • F.binary_cross_entropy、nn.BCELoss、nn.BCEWithLogitsLoss与F.kl_div函数详细解读
  • 后端接口性能优化分析
  • 【ceph】ceph集群中使用多路径(Multipath)方法
  • Xshell+Xftp通过代理的方式访问局域网内网服务器
  • 对盒子中的材料进行计数
  • 科技驱动固定资产管理变革:RFID技术的前沿应用
  • Django路由层之有名分组和无名分组、反向解析、路由分发、伪静态的概念、名称空间、虚拟环境、Django1和Django2的区别
  • 【nlp】2.5 人名分类器实战项目(对比RNN、LSTM、GRU模型)
  • 海康Visionmaster-环境配置:MFC 二次开发环境配置方法
  • 利用EXCEL中的VBA对同一文件夹下的多个数据文件进行特定提取
  • FPGA时序约束(七)文献时序约束实验测试
  • 【数据库开发】DataX开发环境的安装部署(Python、Java)
  • Flutter实践一:package组织
  • SpringCloud微服务:Ribbon负载均衡
  • 【教程】大气化学在线耦合模式WRF/Chem
  • GDS 命令的使用 srvctl service TAF application continuity
  • go 语言之 select
  • 23款奔驰GLC260L升级小柏林音响 全新15个扬声器
  • ssh 免密码登录
  • 小程序使用腾讯位置插件获取当前位置
  • 零基础学Python怎么学习?我来告诉你
  • 开源软件 FFmpeg 生成模型使用图片数据集
  • Linux Shell 通配符 / glob 模式
  • 深入了解域名与SSL证书的关系