flatter.io(dart)-如何创建左填充覆盖?

flatter.io(dart)-如何创建左填充覆盖?,dart,flutter,Dart,Flutter,在颤振中,容器具有填充物: padding: const EdgeInsets.only( left: MyMeasurements.globalLeftPadding, right: 20.0, ), 我希望能够覆盖“左” 如果执行此操作,则会出现运行时错误: class MySectionHeader extends StatelessWidget { final double left; MySectionHeader({ this.left, }); // do

在颤振中,容器具有填充物:

padding: const EdgeInsets.only(
  left: MyMeasurements.globalLeftPadding,
  right: 20.0,
),
我希望能够覆盖“左”

如果执行此操作,则会出现运行时错误:

class MySectionHeader extends StatelessWidget {
    final double left;

MySectionHeader({
  this.left,
});

// down to the widget body
padding: const EdgeInsets.only(
  left: left ?? MyMeasurements.globalLeftPadding,
  right: 20.0,
),

// and in the container that has the override...
new MySectionHeader(
  left: 12.0,
),
padding: const EdgeInsets.only(
  left: left ?? 14.0,
  right: 20.0,
),

// and in the container that has the override...
new MySectionHeader(
  left: 12.0,
),
这还将获得一个运行时错误:

class MySectionHeader extends StatelessWidget {
    final double left;

MySectionHeader({
  this.left,
});

// down to the widget body
padding: const EdgeInsets.only(
  left: left ?? MyMeasurements.globalLeftPadding,
  right: 20.0,
),

// and in the container that has the override...
new MySectionHeader(
  left: 12.0,
),
padding: const EdgeInsets.only(
  left: left ?? 14.0,
  right: 20.0,
),

// and in the container that has the override...
new MySectionHeader(
  left: 12.0,
),

建议?

您不能同时使用
const
构造函数和动态内容。 只执行新边设置()