Flutter 移除 Material Stepper 的内置框阴影

问题描述 投票:0回答:2

我在我的桌面应用程序中使用了 Material Design 的 Stepper 和 Flutter。但如图所示,Stepper 有一个默认的 BoxShadow,我想将其删除。我已经查看了构建步进器的 stepper.dart 文件,但我找不到任何会导致阴影的装饰。

enter image description here

这是我的 Stepper 实现的摘录:

child: Padding(
  padding: const EdgeInsets.all(80.0),
  child: Stepper(
    steps: steps,
    type: StepperType.horizontal,
    currentStep: currentStep,
    onStepContinue: next,
    onStepCancel: cancel,
    onStepTapped: (step) => goTo(step),
  ),
),

我猜测这是材料设计中的某种配置,它会自动为步进器分配阴影。

有没有办法配置/删除步进器的阴影?

flutter material-design
2个回答
0
投票

如果你进入源代码,你会看到

Material
小部件和
elevation: 2.0

所以,我认为你有两个选择:

  1. 根据源代码创建您自己的步进器(删除高程属性)
  2. 像这样将阴影颜色设置为透明
Theme(
  data: ThemeData(shadowColor: Colors.transparent),
  child: Padding(
    padding: const EdgeInsets.all(80.0),
    child: Stepper(
      steps: steps,
      type: StepperType.horizontal,
      currentStep: currentStep,
      onStepContinue: next,
      onStepCancel: cancel,
      onStepTapped: (step) => goTo(step),
    ),
  ),
),

0
投票

我认为如果您询问步进器的标高属性,通常它会给出步进器中的阴影和标高

步进器( 海拔:0, 类型:StepperType.horizontal, 当前步骤:当前步骤, 连接器颜色:MaterialStateProperty.resolveWith(getColors), onStepCancel: () => 当前步骤 == 0 ?无效的 : 设置状态(() { 当前步数=当前步数-1; }), onStepContinue: () { bool isLastStep = (currentStep == getSteps().length - 1); 如果(是最后一步){ } 别的 { 设置状态((){ 当前步数 += 1; }); } }, onStepTapped: (步骤) => setState(() { 当前步=步; }), 步骤: getSteps(), ),

以这种设置海拔的方式:我认为0会起作用。

© www.soinside.com 2019 - 2024. All rights reserved.