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

Flutter组件————AppBar

AppBar 是 Flutter 中用于创建应用程序顶部栏的组件,它遵循 Material Design 规范。

参数:

参数名称类型描述
titleWidget设置 AppBar 中的标题文本或自定义标题小部件。
automaticallyImplyLeadingbool决定是否自动添加返回按钮(如果页面不是首页)。
leadingWidget设置 AppBar 左侧的控件,如菜单图标或自定义小部件。
actionsList<Widget>设置 AppBar 右侧的操作按钮列表。
elevationdouble定义 AppBar 下方阴影的高度。
centerTitlebool决定 title 是否居中显示,默认值根据平台而异。
backgroundColorColor设置 AppBar 的背景颜色。
foregroundColorColor设置 AppBar 内部元素的颜色,例如标题和操作按钮的颜色。
shadowColorColor设置 AppBar 阴影的颜色。
surfaceTintColorColor设置 AppBar 表面高光的颜色。
toolbarHeightdouble设置 AppBar 的总高度。
bottomPreferredSizeWidget设置 AppBar 底部的小部件,如 TabBar
shapeShapeBorder定义 AppBar 的形状,例如圆角矩形等。
iconThemeIconThemeData用于定义 AppBar 内部图标的样式。
primarybool指示此 AppBar 是否是屏幕的主要工具栏。
titleSpacingdouble定义 title 周围的间距。

代码示例

class MyHomePage extends StatefulWidget {const MyHomePage({super.key});State<MyHomePage> createState() => _MyHomePageState();
}class _MyHomePageState extends State<MyHomePage> {//所有右侧行为按钮List<Widget> actionList = const [Icon(Icons.social_distance),SizedBox(width: 30,),Icon(Icons.cyclone),SizedBox(width: 30,),Icon(Icons.manage_accounts),SizedBox(width: 40,)];Widget build(BuildContext context) {return Scaffold(appBar: AppBar(backgroundColor: Theme.of(context).colorScheme.inversePrimary, //背景颜色foregroundColor: const Color.fromARGB(135, 226, 5, 255),leading: const Icon(Icons.accessibility_new_rounded), //左侧按钮title: const Text("Flutter 示例"), //标题actions: actionList, //右侧按钮elevation: 10, //下方阴影shadowColor: const Color.fromARGB(136, 0, 225, 255), //阴影颜色centerTitle: true, // 标题是否居中(ios默认居中,Android默认居左)surfaceTintColor: const Color.fromARGB(172, 249, 128, 0), //表面颜色toolbarHeight: 45, //顶部栏高度iconTheme: const IconThemeData(size: 30, color: Color.fromARGB(207, 255, 251, 0)), //控制内部元素样式primary: true, // 是否显示主要按钮titleSpacing: 100, //标题内边距bottom: const TabBar(tabs: [Tab(icon: Icon(Icons.directions_car)),Tab(icon: Icon(Icons.directions_transit)),Tab(icon: Icon(Icons.directions_bike)),]), //顶部栏底部按钮shape:const  RoundedRectangleBorder(borderRadius: BorderRadius.vertical(bottom: Radius.circular(15))  //顶部栏底部按钮样式),), //顶部栏body: Center(child: ListView(children: [],),),);}
}

效果

在这里插入图片描述

http://www.lryc.cn/news/507148.html

相关文章:

  • 请问深度学习直接缝了别的模型,在论文中这种创新点应该如何描述呢?
  • 微流控专题 | 微流体应用说明——藻酸盐微球生产简介
  • 【前后端】HTTP网络传输协议
  • Fastdfs V6.12.1集群部署(arm/x86均可用)
  • 【LeetCode每日一题】——434.字符串中的单词数
  • windows C#-使用构造函数
  • [react]redux异步处理和重写useDispatch
  • 基础数据结构---栈
  • 【HarmonyOS之旅】DevEco Studio的安装与环境配置
  • Liveweb视频融合共享平台在果园农场等项目中的视频监控系统搭建方案
  • Android4.4 在系统中添加自己的System Service
  • 【C++】C++实现字符串大小写转换功能
  • 【蓝桥杯】43696.小数第n位
  • 进程间通信方式---消息队列(System V IPC)
  • windows10 安装wsl、迁移到其他盘
  • el-divide(vue3总)
  • python —— 常用命令行的命令
  • C++ 23版的最新特性
  • 什么是 Memory-bound stalls,以及如何优化
  • 机器学习 | 非线性回归拟合数据时的离群值检测
  • 使用elasticsearch-head插件修改elasticsearch数据
  • 202412月最新植物大战僵尸杂交版【V3.0.1】更新内容与下载
  • 游戏渠道假量解决方案
  • Java系统对接企业微信审批项目流程
  • 基于Springboot人口老龄化社区服务与管理平台【附源码】
  • Dot Foods EDI 需求分析及对接流程
  • 代码随想录day24 | leetcode 93.复原IP地址 90.子集 90.子集II
  • 探索国产数字隔离器——测试与应用
  • IDEA无法打开插件市场的解决
  • 以腾讯混元模型为例,在管理平台上集成一个智能助手