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) {