我对使用Widget
函数和class
(stf,stl)创建自定义小部件之间的良好实践感到困惑.
For the example about creating the custom widget with the 100 function:
class FieldCustomWidget {
static Widget textField(...) {
return ...;
}
static Widget idCardNumberField(...) {
return ...;
}
static Widget phoneField(...) {
return ...;
}
}
For the example about creating the custom widget with the 100 (stf,stl):
class TextFieldCustomWidget extends StatelessWidget {
...
const TextFieldCustomWidget ({Key? key, ...}) : super(key: key);
@override
Widget build(BuildContext context) {
return ...;
}
}
class IdCardNumberFieldCustomWidget extends StatelessWidget {
...
const IdCardNumberFieldCustomWidget ({Key? key, ...}) : super(key: key);
@override
Widget build(BuildContext context) {
return ...;
}
}
class PhoneFieldCustomWidget extends StatelessWidget {
...
const PhoneFieldCustomWidget ({Key? key, ...}) : super(key: key);
@override
Widget build(BuildContext context) {
return ...;
}
}
所有客户小部件都可以使用Widget
函数或stl
,因为我使用的是state management.
什么是好的实践?
如果你有其他办法,请告诉我.