selectChatDrawer function

Future<String?> selectChatDrawer({
  1. required dynamic context,
  2. dynamic key = selectChatDrawerKey,
  3. String canCheck = 'CanInvite',
  4. String? currentChatId,
  5. dynamic title,
})

Implementation

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