在 Flutter 中扩展 Material 个组件
Extending Material Components in Flutter
我想创建一组从 Material 组件扩展的自定义小部件。
哪种方法更好?
来自docs
Rather than having each widget provide a large number of parameters, Flutter embraces composition. Widgets are built out of smaller widgets that you can reuse and combine in novel ways to make custom widgets. For example, rather than subclassing a generic button widget, RaisedButton combines a Material widget with a GestureDetector widget. The Material widget provides the visual design and the GestureDetector widget provides the interaction design.
这意味着不应扩展小部件,这就是为什么没有示例或教程如何进行扩展的原因。
但是您仍然可以查找小部件的源代码并创建一个新的小部件来满足您的需要
我想创建一组从 Material 组件扩展的自定义小部件。 哪种方法更好?
来自docs
Rather than having each widget provide a large number of parameters, Flutter embraces composition. Widgets are built out of smaller widgets that you can reuse and combine in novel ways to make custom widgets. For example, rather than subclassing a generic button widget, RaisedButton combines a Material widget with a GestureDetector widget. The Material widget provides the visual design and the GestureDetector widget provides the interaction design.
这意味着不应扩展小部件,这就是为什么没有示例或教程如何进行扩展的原因。
但是您仍然可以查找小部件的源代码并创建一个新的小部件来满足您的需要