You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter如何自定义AppBar样式:修改背景、去除阴影、居中标题

修改后完整代码

appBar: AppBar(
  // 移除默认阴影
  elevation: 0,
  // 开启标题居中
  centerTitle: true,
  // 自定义背景色,可替换为你需要的颜色值
  backgroundColor: Colors.white,
  title: Text(
    "Deskripsi",
    style: blackTextStyle.copyWith(
      fontWeight: semiBold,
    ),
  ),
),

配置说明

  • elevation:控制AppBar的阴影高度,赋值为0即可完全去除默认阴影效果
  • centerTitle:控制标题对齐方式,赋值为true即可让标题在AppBar中居中展示
  • backgroundColor:控制AppBar的背景颜色,支持传入任意Color类型值,比如自定义十六进制色值Color(0xFFF0F0F0)也可生效

补充说明:原代码中标题文本Deskripsi为印尼语,中文翻译为“描述”,你可以根据业务需求替换为对应的中文文本。

内容的提问来源于stack exchange,提问作者Alan Ichsan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 09:54:07