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

滚动菜单 flutter

想实现这个功能:

在这里插入图片描述

下面的代码可以实现:

import 'package:flutter/material.dart';void main() => runApp(MyApp());class MyApp extends StatelessWidget {static const String _title = 'Flutter Code Sample';Widget build(BuildContext context) {return MaterialApp(title: _title,home: MyStatefulWidget(),);}
}class MyStatefulWidget extends StatefulWidget {MyStatefulWidget({Key key}) : super(key: key);_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}class _MyStatefulWidgetState extends State<MyStatefulWidget> {int _selectedIndex = 0;Widget build(BuildContext context) {return Scaffold(body: Row(children: <Widget>[LayoutBuilder(builder: (context, constraint) {return SingleChildScrollView(child: ConstrainedBox(constraints: BoxConstraints(minHeight: constraint.maxHeight),child: IntrinsicHeight(child: NavigationRail(selectedIndex: _selectedIndex,onDestinationSelected: (int index) {setState(() {_selectedIndex = index;});},labelType: NavigationRailLabelType.selected,destinations: [NavigationRailDestination(icon: Icon(Icons.favorite_border),selectedIcon: Icon(Icons.favorite),label: Text('First'),),NavigationRailDestination(icon: Icon(Icons.bookmark_border),selectedIcon: Icon(Icons.book),label: Text('Second'),),NavigationRailDestination(icon: Icon(Icons.star_border),selectedIcon: Icon(Icons.star),label: Text('Third'),),NavigationRailDestination(icon: Icon(Icons.favorite_border),selectedIcon: Icon(Icons.favorite),label: Text('First'),),NavigationRailDestination(icon: Icon(Icons.bookmark_border),selectedIcon: Icon(Icons.book),label: Text('Second'),),NavigationRailDestination(icon: Icon(Icons.star_border),selectedIcon: Icon(Icons.star),label: Text('Third'),),NavigationRailDestination(icon: Icon(Icons.bookmark_border),selectedIcon: Icon(Icons.book),label: Text('Second'),),NavigationRailDestination(icon: Icon(Icons.star_border),selectedIcon: Icon(Icons.star),label: Text('Third'),),NavigationRailDestination(icon: Icon(Icons.favorite_border),selectedIcon: Icon(Icons.favorite),label: Text('First'),),NavigationRailDestination(icon: Icon(Icons.bookmark_border),selectedIcon: Icon(Icons.book),label: Text('Second'),),NavigationRailDestination(icon: Icon(Icons.star_border),selectedIcon: Icon(Icons.star),label: Text('Third'),),NavigationRailDestination(icon: Icon(Icons.bookmark_border),selectedIcon: Icon(Icons.book),label: Text('Second'),),NavigationRailDestination(icon: Icon(Icons.star_border),selectedIcon: Icon(Icons.star),label: Text('Third'),),NavigationRailDestination(icon: Icon(Icons.favorite_border),selectedIcon: Icon(Icons.favorite),label: Text('First'),),NavigationRailDestination(icon: Icon(Icons.bookmark_border),selectedIcon: Icon(Icons.book),label: Text('Second'),),NavigationRailDestination(icon: Icon(Icons.star_border),selectedIcon: Icon(Icons.star),label: Text('Third'),),],),),),);},),VerticalDivider(thickness: 1, width: 1),// This is the main content.Expanded(child: Center(child: Text('selectedIndex: $_selectedIndex'),),)],),);}
}
http://www.lryc.cn/news/162670.html

相关文章:

  • javaee springMVC数字类型转换之通过注解的方式
  • SQL中CASE的用法
  • 自己的碎碎念集合
  • 暂定名「码道功成:Coder启示录」
  • Apache HTTPD (CVE-2017-15715)换行解析漏洞复现
  • Spring Boot集成JasperReport生成文档
  • 02-Tomcat打破双亲委派机制
  • 怎么理解flink的异步检查点机制
  • SpringMVC <url-pattern/>解读
  • 大学毕业设计的益处:培养实践能力、深入专业领域、展示自信与建立联系
  • ChatGPT:概述Vue.js中data函数初始化和created钩子函数调用的顺序和问题解决方法
  • SpringBoot【基础篇】
  • Vuex - state 状态(获取和使用共享数据)
  • tcp连接+套接字编程
  • OpenCV(三十四):轮廓外接最大、最小矩形和多边形拟合
  • Kafka3.0.0版本——消费者(offset的默认维护位置)
  • Wireshark技巧[监听串口包]
  • 安全运营中心即服务提供商评估
  • 算法通关村第十三关——幂运算问题解析
  • Python 之使用Numpy库来加载Numpy(.npy)文件并检查其内容
  • C#学习系列之UDP同端口收发问题
  • SpringMVC之文件上传下载以及jrebel的使用
  • 基于Fomantic UI Web构建 个人导航站点网站源码 网站技术导航源码
  • DRF02-请求响应与路由
  • http直接调用paddlepaddle实现文字转语音,语音转文字
  • 9. xaml ComboBox控件
  • 【后量子密码】CRYSTALS-KYBER 算法(二):密钥封装 KEM(附源码分析)
  • 什么是原⼦操作?在 JUC 中有哪些原⼦类?
  • 2022年12月 C/C++(八级)真题解析#中国电子学会#全国青少年软件编程等级考试
  • Hadoop的HDFS的集群安装部署