首页 > 解决方案 > Flutter 从父小部件继承所有道具

问题描述

我想在颤动上制作自定义按钮。这是一些代码:

// class LoadingButton.dart

MaterialButton(
  padding: EdgeInsets.all(Spacing().value(2)),
  textColor: Colors.white,
  disabledColor: Colors.grey[100],
  ...props
);

如何动态添加道具而不一一说明构造函数?

我试过使用...props,但它不会添加到道具中。

谢谢

标签: flutter

解决方案


Dart 中没有这样的东西。只有复制粘贴所有属性才有效。


推荐阅读