From 4167291d49061de0a1c5c35dcee36ed79fdf0008 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Mon, 12 Jun 2023 22:41:19 +0200 Subject: [PATCH] neon_news, neon_notes: use records in dialogs --- packages/neon/neon_news/lib/dialogs/add_feed.dart | 2 +- .../neon_news/lib/widgets/feed_floating_action_button.dart | 5 +++-- packages/neon/neon_notes/lib/dialogs/create_note.dart | 2 +- .../lib/widgets/notes_floating_action_button.dart | 7 ++++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/neon/neon_news/lib/dialogs/add_feed.dart b/packages/neon/neon_news/lib/dialogs/add_feed.dart index e5b1839f..294b2188 100644 --- a/packages/neon/neon_news/lib/dialogs/add_feed.dart +++ b/packages/neon/neon_news/lib/dialogs/add_feed.dart @@ -22,7 +22,7 @@ class _NewsAddFeedDialogState extends State { void submit() { if (formKey.currentState!.validate()) { - Navigator.of(context).pop([controller.text, widget.folderID ?? folder?.id]); + Navigator.of(context).pop((controller.text, widget.folderID ?? folder?.id)); } } diff --git a/packages/neon/neon_news/lib/widgets/feed_floating_action_button.dart b/packages/neon/neon_news/lib/widgets/feed_floating_action_button.dart index edb43e99..f1b6455a 100644 --- a/packages/neon/neon_news/lib/widgets/feed_floating_action_button.dart +++ b/packages/neon/neon_news/lib/widgets/feed_floating_action_button.dart @@ -13,7 +13,7 @@ class NewsFeedFloatingActionButton extends StatelessWidget { @override Widget build(final BuildContext context) => FloatingActionButton( onPressed: () async { - final result = await showDialog( + final result = await showDialog<(String, int?)>( context: context, builder: (final context) => NewsAddFeedDialog( bloc: bloc, @@ -21,7 +21,8 @@ class NewsFeedFloatingActionButton extends StatelessWidget { ), ); if (result != null) { - bloc.addFeed(result[0] as String, result[1] as int?); + final (url, folderId) = result; + bloc.addFeed(url, folderId); } }, tooltip: AppLocalizations.of(context).feedAdd, diff --git a/packages/neon/neon_notes/lib/dialogs/create_note.dart b/packages/neon/neon_notes/lib/dialogs/create_note.dart index 2f017b0d..36b1b9ce 100644 --- a/packages/neon/neon_notes/lib/dialogs/create_note.dart +++ b/packages/neon/neon_notes/lib/dialogs/create_note.dart @@ -21,7 +21,7 @@ class _NotesCreateNoteDialogState extends State { void submit() { if (formKey.currentState!.validate()) { - Navigator.of(context).pop([controller.text, widget.category ?? selectedCategory]); + Navigator.of(context).pop((controller.text, widget.category ?? selectedCategory)); } } diff --git a/packages/neon/neon_notes/lib/widgets/notes_floating_action_button.dart b/packages/neon/neon_notes/lib/widgets/notes_floating_action_button.dart index 533e1eb3..822f0e27 100644 --- a/packages/neon/neon_notes/lib/widgets/notes_floating_action_button.dart +++ b/packages/neon/neon_notes/lib/widgets/notes_floating_action_button.dart @@ -13,7 +13,7 @@ class NotesFloatingActionButton extends StatelessWidget { @override Widget build(final BuildContext context) => FloatingActionButton( onPressed: () async { - final result = await showDialog( + final result = await showDialog<(String, String?)>( context: context, builder: (final context) => NotesCreateNoteDialog( bloc: bloc, @@ -21,9 +21,10 @@ class NotesFloatingActionButton extends StatelessWidget { ), ); if (result != null) { + final (title, category) = result; bloc.createNote( - title: result[0] as String, - category: result[1] as String? ?? '', + title: title, + category: category ?? '', ); } },