forceRebuild method Null safety

  1. @protected
Future<void> forceRebuild()
protected">@protected

Cause the entire tree to be rebuilt. This is used by development tools when the application code has changed and is being hot-reloaded, to cause the widget tree to pick up any changed implementations.

This is expensive and should not be called except during development.

Implementation

@protected
Future<void> forceRebuild() {
  final WidgetsBinding binding = WidgetsBinding.instance;
  if (binding.renderViewElement != null) {
    binding.buildOwner!.reassemble(binding.renderViewElement!, null);
    return binding.endOfFrame;
  }
  return Future<void>.value();
}