diff --git a/lib/src/home/providers/file_provider.dart b/lib/src/home/providers/file_provider.dart index d1e09f3..0477962 100644 --- a/lib/src/home/providers/file_provider.dart +++ b/lib/src/home/providers/file_provider.dart @@ -72,6 +72,7 @@ class _FilesNotifier extends StateNotifier> { path: Uri.file(pathStr), ); final res = FileService.createOrUpdateFile(file); + return res.map((r) { newState.add(file); state = newState; diff --git a/lib/src/home/widgets/drawer.dart b/lib/src/home/widgets/drawer.dart index e141604..fbf8525 100644 --- a/lib/src/home/widgets/drawer.dart +++ b/lib/src/home/widgets/drawer.dart @@ -45,7 +45,10 @@ class _DrawerWidgetState extends ConsumerState { final fileNotifier = ref.watch(filesProvider.notifier); final activeFile = ref.watch(activeFileProvider); final docDir = appDocumentsDirectory.match( - () => '', (t) => t.path.replaceAll('\\', '/')); + () => '', + (t) => t.path.replaceAll('\\', '/'), + ); + final files = ref.watch(filesProvider); return Drawer( backgroundColor: globalTheme.primaryColor, @@ -153,6 +156,7 @@ class _DrawerWidgetState extends ConsumerState { .run() .then( (value) { + Navigator.of(context).pop(); value.match( (l) => context .showErrorSnackBar(l.message), @@ -162,7 +166,6 @@ class _DrawerWidgetState extends ConsumerState { action: const None(), ), ); - Navigator.of(context).pop(); }, ); }, @@ -183,8 +186,7 @@ class _DrawerWidgetState extends ConsumerState { ), Expanded( child: ListView( - children: ref - .watch(filesProvider) + children: files .map( (e) => ListTile( tileColor: globalTheme.secondaryColor,