From b4fd093e7c6227b90c99f1100b06277d6e900dbb Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 6 Mar 2025 11:51:39 -0600 Subject: [PATCH] Create management portal in Flutter #39 --- .../lib/screens/add_mount_screen.dart | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/web/repertory/lib/screens/add_mount_screen.dart b/web/repertory/lib/screens/add_mount_screen.dart index 62b40234..880f4e25 100644 --- a/web/repertory/lib/screens/add_mount_screen.dart +++ b/web/repertory/lib/screens/add_mount_screen.dart @@ -65,11 +65,7 @@ class _AddMountScreenState extends State { const SizedBox(width: _padding), DropdownButton( value: _mountType, - onChanged: (newValue) { - setState(() { - _mountType = newValue ?? ""; - }); - }, + onChanged: (mountType) => _handleChange(mountType ?? ''), items: providerTypeList.map>(( item, @@ -100,21 +96,7 @@ class _AddMountScreenState extends State { 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 { ); } + 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) {