I am confused about good practice between creating the custom widget with the Widget
function and the class
(stf,stl).
For the example about creating the custom widget with the Widget
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 class
(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 ...;
}
}
All customer widgets can use the Widget
function or stl
because I am using state management.
What is good practice?
If you have another way, please tell me.