selectSpaceDrawer function

Future<String?> selectSpaceDrawer({
  1. required dynamic context,
  2. dynamic key = selectSpaceDrawerKey,
  3. String canCheck = 'CanLinkSpaces',
  4. String? currentSpaceId,
  5. dynamic title,
})

Implementation

Future<String?> selectSpaceDrawer({
  required BuildContext context,
  Key? key = selectSpaceDrawerKey,
  String canCheck = 'CanLinkSpaces',
  String? currentSpaceId,
  Widget? title,
}) async {
  final selected = await showModalBottomSheet(
    showDragHandle: true,
    enableDrag: true,
    context: context,
    isDismissible: true,
    builder: (context) => SelectRoomDrawer(
      key: key,
      canCheck: canCheck,
      currentSpaceId: currentSpaceId,
      title: title ?? Text(L10n.of(context).selectSpace),
      keyPrefix: 'select-space',
      roomType: RoomType.space,
    ),
  );
  if (selected == null) {
    // in case of being dismissed, we return the previously selected item
    return currentSpaceId;
  }
  if (selected == '') {
    // in case of being cleared, we return null
    return null;
  }
  return selected;
}