From 847bf68f853c1cc34d365d91eda2c5098740dee1 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 5 Mar 2025 20:38:15 -0600 Subject: [PATCH] refactor --- web/repertory/lib/main.dart | 100 ++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/web/repertory/lib/main.dart b/web/repertory/lib/main.dart index 4dc28f31..aff9126c 100644 --- a/web/repertory/lib/main.dart +++ b/web/repertory/lib/main.dart @@ -144,62 +144,60 @@ class _MyHomePageState extends State { floatingActionButton: FloatingActionButton( onPressed: _allowAdd - ? () { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: const Text('Add Mount'), - content: Consumer( - builder: (_, MountList mountList, __) { - return AddMountWidget( - mountType: _mountType, - onDataChanged: _updateData, - ); + ? () async => showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: const Text('Add Mount'), + content: Consumer( + builder: (_, MountList mountList, __) { + return AddMountWidget( + mountType: _mountType, + onDataChanged: _updateData, + ); + }, + ), + actions: [ + TextButton( + child: const Text('Cancel'), + onPressed: () { + _resetData(); + Navigator.of(context).pop(); }, ), - actions: [ - TextButton( - child: const Text('Cancel'), - onPressed: () { - _resetData(); - Navigator.of(context).pop(); - }, - ), - TextButton( - child: const Text('OK'), - onPressed: () { - setState(() => _allowAdd = false); + TextButton( + child: const Text('OK'), + onPressed: () { + setState(() => _allowAdd = false); - Provider.of(context, listen: false) - .add( - _mountType, - _mountName, - apiPassword: _apiPassword, - apiPort: _apiPort, - bucket: _bucket, - encryptionToken: _encryptionToken, - hostNameOrIp: _hostNameOrIp, - path: _path, - ) - .then((_) { - _resetData(); - setState(() { - _allowAdd = true; - }); - }) - .catchError((_) { - setState(() => _allowAdd = true); + Provider.of(context, listen: false) + .add( + _mountType, + _mountName, + apiPassword: _apiPassword, + apiPort: _apiPort, + bucket: _bucket, + encryptionToken: _encryptionToken, + hostNameOrIp: _hostNameOrIp, + path: _path, + ) + .then((_) { + _resetData(); + setState(() { + _allowAdd = true; }); + }) + .catchError((_) { + setState(() => _allowAdd = true); + }); - Navigator.of(context).pop(); - }, - ), - ], - ); - }, - ); - } + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ) : null, tooltip: 'Add Mount', child: const Icon(Icons.add),