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() {
  scrollController.addListener(_scrollListener);

  blocklist.value = _blocklistService.blocklist.values.toList();
  _sort();

  _blocklistSubscription = _blocklistService.blocklist.items.changes.listen((
    e,
  ) {
    switch (e.op) {
      case OperationKind.added:
        blocklist.add(e.value!);
        _sort();
        break;

      case OperationKind.removed:
        blocklist.removeWhere((c) => c.id == e.key);
        _ensureScrollable();
        break;

      case OperationKind.updated:
        // No-op, as [blocklist] is never updated.
        break;
    }
  });

  super.onInit();
}