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