From 850ff135c0983153cae6f3453b48a5160c7f7de6 Mon Sep 17 00:00:00 2001 From: bitfriend Date: Thu, 17 Oct 2024 16:25:51 +0800 Subject: [PATCH] Apply Options extension with orElse --- app/lib/common/widgets/sliver_scaffold.dart | 5 ++++- .../features/events/pages/create_event_page.dart | 16 ++++++++++------ app/lib/features/events/widgets/event_item.dart | 12 +++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/lib/common/widgets/sliver_scaffold.dart b/app/lib/common/widgets/sliver_scaffold.dart index c3afe8745d81..8c02823c20d7 100644 --- a/app/lib/common/widgets/sliver_scaffold.dart +++ b/app/lib/common/widgets/sliver_scaffold.dart @@ -218,6 +218,9 @@ class _SliverFooter extends StatelessWidget { } void onCancel(BuildContext context) { - cancelActionOnPressed.map((cb) => cb()) ?? Navigator.pop(context); + cancelActionOnPressed.map( + (cb) => cb(), + orElse: () => Navigator.pop(context), + ); } } diff --git a/app/lib/features/events/pages/create_event_page.dart b/app/lib/features/events/pages/create_event_page.dart index 7c206e774aa9..cd070b7fe37f 100644 --- a/app/lib/features/events/pages/create_event_page.dart +++ b/app/lib/features/events/pages/create_event_page.dart @@ -94,14 +94,18 @@ class CreateEventPageConsumerState extends ConsumerState { @override void initState() { super.initState(); - widget.templateEvent.map((p0) { - WidgetsBinding.instance - .addPostFrameCallback((Duration dur) => _setFromTemplate(p0)); - }) ?? + widget.templateEvent.map( + (p0) => WidgetsBinding.instance.addPostFrameCallback((Duration dur) { + _setFromTemplate(p0); + }), + orElse: () { widget.initialSelectedSpace.map((p0) { - WidgetsBinding.instance - .addPostFrameCallback((Duration dur) => _setSpaceId(p0)); + WidgetsBinding.instance.addPostFrameCallback((Duration dur) { + _setSpaceId(p0); + }); }); + }, + ); } @override diff --git a/app/lib/features/events/widgets/event_item.dart b/app/lib/features/events/widgets/event_item.dart index 1a9f7557eabf..39336da17727 100644 --- a/app/lib/features/events/widgets/event_item.dart +++ b/app/lib/features/events/widgets/event_item.dart @@ -37,11 +37,13 @@ class EventItem extends StatelessWidget { return InkWell( onTap: () { final eventId = event.eventId().toString(); - onTapEventItem.map((cb) => cb(eventId)) ?? - context.pushNamed( - Routes.calendarEvent.name, - pathParameters: {'calendarId': eventId}, - ); + onTapEventItem.map( + (cb) => cb(eventId), + orElse: () => context.pushNamed( + Routes.calendarEvent.name, + pathParameters: {'calendarId': eventId}, + ), + ); }, child: Stack( alignment: Alignment.topLeft,