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

如何移除CupertinoNavigationBar底部的灰色条?

移除CupertinoNavigationBar底部灰色条的方法

那个灰色条是CupertinoNavigationBar默认的底部边框,修改backgroundColor不会对它产生影响,你只需要给导航栏添加border: null属性就能直接移除它。

修改后的完整代码如下:

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';

class ModalFitCreate extends StatelessWidget {
  const ModalFitCreate({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
        child: SafeArea(
          top: false,
          child: Container(
            color: const Color(0xFFF5F5F5),
            child: Column(
              children: [
                CupertinoNavigationBar(
                  backgroundColor: Colors.transparent,
                  // 添加该行移除底部灰色边框
                  border: null,
                  automaticallyImplyLeading: false,
                  leading: TextButton(
                    style: ButtonStyle(
                      overlayColor: MaterialStateProperty.all(Colors.transparent),
                    ),
                    onPressed: () {
                      Navigator.pop(context);
                    },
                    child: const Text(
                      'Cancel',
                      style: TextStyle(
                        fontSize: 16,
                      )
                    )
                  ),
                  middle: const Text(
                    'New Event',
                    style: TextStyle(
                      fontSize: 16,
                    )
                  ),
                  trailing: TextButton(
                      style: ButtonStyle(
                        overlayColor: MaterialStateProperty.all(Colors.transparent),
                      ),
                      onPressed: () {},
                      child: const Text(
                          'Add',
                        style: TextStyle(
                          fontSize: 16,
                          fontWeight: FontWeight.bold,
                        )
                      )
                  ),
                ),
              ],
            )
          )
        ));
  }
}

如果需要保留边框结构但隐藏颜色,也可以用以下写法替代border: null:

border: const Border(bottom: BorderSide(color: Colors.transparent))

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 00:45:39