CrySelect constructor

CrySelect({
  1. Key? key,
  2. double? width,
  3. String? label,
  4. String? value,
  5. ValueChanged? onChange,
  6. FormFieldSetter? onSaved,
  7. List<SelectOptionVO> dataList = const [],
})

Implementation

CrySelect({
  Key? key,
  double? width,
  String? label,
  String? value,
  ValueChanged? onChange,
  FormFieldSetter? onSaved,
  List<SelectOptionVO> dataList = const [],
}) : super(
        key: key,
        width: width,
        builder: (CryFormFieldState state) {
          return DropdownButtonFormField<String>(
            decoration: InputDecoration(
              contentPadding: EdgeInsets.symmetric(horizontal: 10),
              labelText: label,
            ),
            value: value,
            items: dataList.map((v) {
              return DropdownMenuItem<String>(
                value: v.value as String?,
                child: Text(v.label!),
              );
            }).toList(),
            onChanged: (v) {
              value = v;
              if (onChange != null) {
                onChange(v);
              }
              state.didChange();
            },
            onSaved: onSaved,
          );
        },
      );