40 lines
1.9 KiB
Dart
40 lines
1.9 KiB
Dart
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class SubDropdownInputWidget extends StatefulWidget {
|
||
|
String subkey;
|
||
|
double width;
|
||
|
bool empty;
|
||
|
List<DropdownMenuItem<String>> dropdownMenuEntries = [];
|
||
|
void Function(String?)? change = (value) {};
|
||
|
SubDropdownInputWidget ({ Key? key, required this.dropdownMenuEntries,
|
||
|
required this.subkey, required this.width, required this.empty, required this.change }): super(key: key);
|
||
|
@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(
|
||
|
items: widget.dropdownMenuEntries,
|
||
|
onChanged: widget.change,
|
||
|
style: const TextStyle(fontSize: 12),
|
||
|
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),
|
||
|
),
|
||
|
))),
|
||
|
]);
|
||
|
}
|
||
|
}
|