oc-front/lib/widgets/inputs/sub_dropdown_input .dart
2025-02-05 09:07:39 +01:00

43 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
class SubDropdownInputWidget extends StatefulWidget {
String subkey;
double width;
bool empty;
String? initialValue;
List<DropdownMenuItem<String>> dropdownMenuEntries = [];
void Function(String?)? change = (value) {};
SubDropdownInputWidget ({ super.key, required this.dropdownMenuEntries, this.initialValue,
required this.subkey, required this.width, required this.empty, required this.change });
@override SubDropdownInputWidgetState createState() => SubDropdownInputWidgetState();
}
class SubDropdownInputWidgetState extends State<SubDropdownInputWidget> {
@override Widget build(BuildContext context) {
return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Tooltip( message: widget.subkey,
child: Container( margin: EdgeInsets.only(top: widget.empty ? 0 : 15),
width: widget.width, height: 30,
child: DropdownButtonFormField(
isExpanded: true,
items: widget.dropdownMenuEntries,
value: widget.initialValue,
onChanged: widget.change,
style: const TextStyle(fontSize: 12,color: Colors.black, overflow: TextOverflow.ellipsis),
decoration: InputDecoration(
hintText: "select ${widget.subkey}...",
fillColor: Colors.white,
filled: true,
labelText: widget.subkey,
alignLabelWithHint: false,
errorStyle: const TextStyle(fontSize: 0),
hintStyle: const TextStyle(fontSize: 10),
labelStyle: const TextStyle(fontSize: 10),
floatingLabelBehavior: FloatingLabelBehavior.always,
enabledBorder: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
border: const OutlineInputBorder(borderSide: BorderSide(color: Colors.grey)),
contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
))),
]);
}
}