Skip to content

Commit

Permalink
Minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
dhzdhd committed Apr 12, 2023
1 parent 968f703 commit 9e3e2ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/src/home/providers/file_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class _FilesNotifier extends StateNotifier<List<FileModel>> {
path: Uri.file(pathStr),
);
final res = FileService.createOrUpdateFile(file);

return res.map((r) {
newState.add(file);
state = newState;
Expand Down
10 changes: 6 additions & 4 deletions lib/src/home/widgets/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ class _DrawerWidgetState extends ConsumerState<DrawerWidget> {
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,
Expand Down Expand Up @@ -153,6 +156,7 @@ class _DrawerWidgetState extends ConsumerState<DrawerWidget> {
.run()
.then(
(value) {
Navigator.of(context).pop();
value.match(
(l) => context
.showErrorSnackBar(l.message),
Expand All @@ -162,7 +166,6 @@ class _DrawerWidgetState extends ConsumerState<DrawerWidget> {
action: const None(),
),
);
Navigator.of(context).pop();
},
);
},
Expand All @@ -183,8 +186,7 @@ class _DrawerWidgetState extends ConsumerState<DrawerWidget> {
),
Expanded(
child: ListView(
children: ref
.watch(filesProvider)
children: files
.map(
(e) => ListTile(
tileColor: globalTheme.secondaryColor,
Expand Down

0 comments on commit 9e3e2ea

Please sign in to comment.