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() {
  _scheduleRebuild();

  for (var e in _profiles.values) {
    accounts.add(e);
  }
  accounts.sort(_compareAccounts);

  _profilesSubscription = _profiles.changes.listen((e) async {
    switch (e.op) {
      case OperationKind.added:
        accounts.add(e.value!);
        accounts.sort(_compareAccounts);
        break;

      case OperationKind.removed:
        accounts.removeWhere((u) => u.value.id == e.key);
        break;

      case OperationKind.updated:
        accounts.sort(_compareAccounts);
        break;
    }
  });

  super.onInit();
}