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

Flutter_学习记录_AppBar中取消leading的占位展示

  • leading设置为null
  • automaticallyImplyLeading设置为false

看看automaticallyImplyLeading的说明:

Controls whether we should try to imply the leading widget if null.
If true and [AppBar.leading] is null, automatically try to deduce what the leading widget should be. If false and [AppBar.leading] is null, leading space is given to [AppBar.title]. If leading widget is not null, this parameter has no effect.

意思就是说:

  • 如果leading为null 并且 automaticallyImplyLeading为true , 那么会保留leading的占位位置;
  • 如果如果leading为null 并且automaticallyImplyLeading为false , 那么会将leading的位置让给title;
  • 如果leading不为null , automaticallyImplyLeading这个设置失效。

代码如下:


  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
      	
        leading: null,
        automaticallyImplyLeading: false,
        title: Container(
            margin: EdgeInsets.fromLTRB(0, 0, 0, 0), 
            height: Screenadapter.height(100),
            width:  Screenadapter.width(880) ,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(20),
              color: Color.fromARGB(10, 0, 0, 0)
            ),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0), child: Icon(Icons.search, color: Colors.black26)),
                Expanded(child: Text("耳机", style: TextStyle(color: Colors.black45, fontSize: Screenadapter.fontSize(36)))),
                Padding(padding: EdgeInsets.fromLTRB(0, 0, 10, 0), child: Icon(FangXMIcon.saomiao, color: Colors.black26)),
              ],
            ),
          ),
        centerTitle: true,
        actions: [
          Container(
            padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
            width: Screenadapter.width(124),
            height: Screenadapter.height(100),
            child: InkWell(
              child: Icon(FangXMIcon.xiaoxi, color: Colors.black54 ),
            ),
          )
        ],
      ),
      body: const Center(
        child: Text(
          'GiveView is working',
          style: TextStyle(fontSize: 20),
        ),
      ),
    );
  }

效果如下:
在这里插入图片描述

http://www.dtcms.com/a/99155.html

相关文章:

  • Python:日志模块操作及基本配置,日志格式化输出
  • Mybatis源码 插件机制
  • Vue3 项目通过 docxtemplater 插件动态渲染 .docx 文档(带图片)预览,并导出
  • 人工智能与软件工程结合的发展趋势
  • 一些常用开发软件下载地址
  • [Python]如何利用Flask搭建一個Web服務器,並透過Ngrok訪問來實現LINE Bot功能?
  • MySQL数据库的操作(mybatis)
  • Spring学习笔记06——bean、java bean、spring bean、POJO几个概念讲解
  • 算法刷题记录——LeetCode篇(1.2) [第11~20题](持续更新)
  • Labview学习记录
  • 杂草YOLO系列数据集4000张
  • 【MySQL基础-16】MySQL DELETE语句:深入理解与应用实践
  • Ray AI - 概述、安装、入门
  • 【HTML 基础教程】HTML <head>
  • Java多线程与高并发专题——Condition 和 wait/notify的关系
  • python:模块
  • app整改报告怎么写?app整改方案分享
  • 液压式精密矫平机——精准掌控,重塑金属平整新高度
  • 【黑马点评】Redis解决集群的session共享问题
  • wait函数等待多个子进程
  • vue3对比vue2新增特性
  • CSS 边框(Border)样式详解
  • 泛目录优化:无极泛目录优化网站,技术解析与风险控制指南
  • Flutter开发There are multiple heroes that share the same tag within a subtree报错
  • C++ explicit
  • 使用Java操作Redis
  • 在 Windows 中查看 Nginx 当前占用的端口
  • 基于高德地图实现地图交互功能的探索与总结
  • 函数式组件中的渲染函数 JSX
  • Python基础教程:从格式化到项目管理