欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 美景 > Flutter_学习记录_AppBar中取消leading的占位展示

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

2025/4/2 8:34:01 来源:https://blog.csdn.net/lyz0925/article/details/146640651  浏览:    关键词: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),),),);}

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

版权声明:

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

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

热搜词