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

如何移除Flutter框架中OutlinedButton组件的默认边框?

Flutter移除OutlinedButton默认边框的解决方案
  • 单组件单独移除边框
    通过OutlinedButton.styleFrom方法将side属性设置为BorderSide.none即可生效,代码示例:
OutlinedButton(
  onPressed: () {},
  style: OutlinedButton.styleFrom(
    side: BorderSide.none,
  ),
  child: const Text('Next Page'),
)

注:原代码中的Pext Page为拼写笔误,已修正为常见用法Next Page

  • 移除全状态下的边框(含按压、悬停、聚焦等交互态)
    如果需要彻底消除所有交互场景下的边框,可通过ButtonStyle统一配置所有状态的侧边样式:
OutlinedButton(
  onPressed: () {},
  style: ButtonStyle(
    side: MaterialStateProperty.all<BorderSide?>(null),
  ),
  child: const Text('Next Page'),
)
  • 全局配置所有OutlinedButton默认无边框
    如果整个应用的OutlinedButton都需要默认不带边框,可在应用根主题中统一设置:
MaterialApp(
  theme: ThemeData(
    outlinedButtonTheme: OutlinedButtonThemeData(
      style: OutlinedButton.styleFrom(side: BorderSide.none),
    ),
  ),
  // 其余应用配置项
)

内容的提问来源于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 23:36:00