onInit method

  1. @override
void onInit()
override

Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.

Implementation

@override
void onInit() {
  membersScrollController.addListener(_scrollListener);

  name = TextFieldState(
    text: chat?.chat.value.name?.val,
    onFocus: (_) async => await _updateChatName(),
  );

  _fetched?.finish();
  _fetched = _ready.startChild('fetch');

  try {
    final FutureOr<RxChat?> fetched = _chatService.get(chatId);

    if (fetched is RxChat?) {
      _applyChat(fetched);
    } else {
      status.value = RxStatus.loading();
      fetched.then(_applyChat);
    }
  } catch (e) {
    _ready.throwable = e;
    _ready.finish(status: const SpanStatus.internalError());
    rethrow;
  }

  super.onInit();
}