onReady method

  1. @override
void onReady()
override

Called 1 frame after onInit(). It is the perfect place to enter navigation events, like snackbar, dialogs, or a new route, or async request.

Implementation

@override
void onReady() {
  _chatService.chats.forEach((_, value) => _onChatAdded(value));
  _subscription = _chatService.chats.changes.listen((event) {
    switch (event.op) {
      case OperationKind.added:
        _onChatAdded(event.value!, true);
        break;

      case OperationKind.removed:
        _chats.remove(event.key)?.dispose();
        break;

      default:
        break;
    }
  });

  PlatformUtils.isFocused.then((value) => _focused = value);

  _onFocusChanged = PlatformUtils.onFocusChanged.listen((focused) async {
    _focused = focused;
    if (_focused) {
      _flashed = false;
    }
  });

  super.onReady();
}