Create management portal in Flutter #39

This commit is contained in:
Scott E. Graves 2025-03-06 11:51:39 -06:00
parent 5e47cdb861
commit b4fd093e7c

View File

@ -65,11 +65,7 @@ class _AddMountScreenState extends State<AddMountScreen> {
const SizedBox(width: _padding),
DropdownButton<String>(
value: _mountType,
onChanged: (newValue) {
setState(() {
_mountType = newValue ?? "";
});
},
onChanged: (mountType) => _handleChange(mountType ?? ''),
items:
providerTypeList.map<DropdownMenuItem<String>>((
item,
@ -100,21 +96,7 @@ class _AddMountScreenState extends State<AddMountScreen> {
autofocus: true,
controller: _mountNameController,
keyboardType: TextInputType.text,
onChanged: (_) {
setState(() {
_mount =
(_mountNameController.text.isEmpty)
? null
: Mount(
MountConfig(
name: _mountNameController.text,
settings: _settings[_mountType],
type: _mountType,
),
isAdd: true,
);
});
},
onChanged: (_) => _handleChange(_mountType),
),
],
),
@ -140,6 +122,23 @@ class _AddMountScreenState extends State<AddMountScreen> {
);
}
void _handleChange(String mountType) {
setState(() {
_mountType = mountType;
_mount =
(_mountNameController.text.isEmpty)
? null
: Mount(
MountConfig(
name: _mountNameController.text,
settings: _settings[_mountType],
type: _mountType,
),
isAdd: true,
);
});
}
@override
void setState(VoidCallback fn) {
if (!mounted) {