setState method

  1. @protected
void setState (void scheduleChangeDetectionAfter())
@protected

Invokes the provided function and schedules change detection to occur.

For implementing @Input():

  @Input()
  set title(String newValue) {
    setState(() {
      titleToRender = newValue;
    });
  }

For reacting to other events (such as RPCs):

  void invokeRpc(RpcService rpcService) async {
    final users = await rpcService.fetchUsers;
    setState(() {
      usersToRender = users;
    });
  }

Only invoke this method within a class that implements ComponentState.

Implementation

@protected
void setState(void Function() scheduleChangeDetectionAfter) {
  scheduleChangeDetectionAfter();
  deliverStateChanges();
}