add editable option
This commit is contained in:
@@ -7,7 +7,7 @@ class MyDropdownField extends StatefulWidget {
|
|||||||
final bool required;
|
final bool required;
|
||||||
final List<String> dropdownOptions;
|
final List<String> dropdownOptions;
|
||||||
final void Function(String?)? onSelect;
|
final void Function(String?)? onSelect;
|
||||||
//final bool editable;
|
final bool editable;
|
||||||
|
|
||||||
const MyDropdownField({
|
const MyDropdownField({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -15,6 +15,7 @@ class MyDropdownField extends StatefulWidget {
|
|||||||
required this.hintText,
|
required this.hintText,
|
||||||
required this.dropdownOptions,
|
required this.dropdownOptions,
|
||||||
required this.required,
|
required this.required,
|
||||||
|
required this.editable,
|
||||||
this.onSelect,
|
this.onSelect,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -100,6 +101,7 @@ class _MyDropdownFieldState extends State<MyDropdownField> {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
||||||
child: DropdownMenu(
|
child: DropdownMenu(
|
||||||
|
enabled: widget.editable,
|
||||||
trailingIcon: Icon(
|
trailingIcon: Icon(
|
||||||
Icons.arrow_drop_down,
|
Icons.arrow_drop_down,
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
@@ -117,9 +119,14 @@ class _MyDropdownFieldState extends State<MyDropdownField> {
|
|||||||
errorText: _errorText,
|
errorText: _errorText,
|
||||||
|
|
||||||
focusNode: _focus,
|
focusNode: _focus,
|
||||||
onSelected: (_) => setState(() {
|
onSelected: (_) {
|
||||||
startup = false;
|
setState(() {
|
||||||
}),
|
startup = false;
|
||||||
|
});
|
||||||
|
// if (widget.editable == false) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
},
|
||||||
leadingIcon: IconButton(
|
leadingIcon: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -149,9 +156,10 @@ class _MyDropdownFieldState extends State<MyDropdownField> {
|
|||||||
fontWeight: FontWeight.bold),
|
fontWeight: FontWeight.bold),
|
||||||
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
fillColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
focusedBorder: OutlineInputBorder(
|
focusedBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor())),
|
),
|
||||||
|
),
|
||||||
focusedErrorBorder: OutlineInputBorder(
|
focusedErrorBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
@@ -170,6 +178,12 @@ class _MyDropdownFieldState extends State<MyDropdownField> {
|
|||||||
width: 2.0,
|
width: 2.0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
disabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
width: 2.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
outlineBorder: BorderSide(
|
outlineBorder: BorderSide(
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user