fromUser static method Null safety

Sender? fromUser(
  1. User? user,
  2. BaseChannel channel
)

Implementation

static Sender? fromUser(User? user, BaseChannel channel) {
  if (user == null) return null;
  final sender = Sender.fromJson(user.toJson());
  if (channel is GroupChannel) {
    sender.role = channel.myRole;
  } else if (channel is OpenChannel) {
    sender.role =
        channel.isOperator(user.userId) ? Role.chat_operator : Role.none;
  }
  return sender;
}