buildWidget method
This is where the actual widget building process happens.
This method tries to reduce widget rebuilds. Rebuild bypass is determined by the following process:
- If oldOptions == newOptions, bypass
- If GreenNode.shouldRebuildWidget, force rebuild
- Call buildWidget on children. If the results are identical to the results returned by buildWidget called last time, then bypass.
Implementation
BuildResult buildWidget(MathOptions options) {
if (value is PositionDependentMixin) {
(value as PositionDependentMixin).updatePos(pos);
}
if (value._oldOptions != null && options == value._oldOptions) {
return value._oldBuildResult!;
}
final childOptions = value.computeChildOptions(options);
final newChildBuildResults = _buildChildWidgets(childOptions);
final bypassRebuild = value._oldOptions != null &&
!value.shouldRebuildWidget(value._oldOptions!, options) &&
listEquals(newChildBuildResults, value._oldChildBuildResults);
value._oldOptions = options;
value._oldChildBuildResults = newChildBuildResults;
return bypassRebuild
? value._oldBuildResult!
: (value._oldBuildResult =
value.buildWidget(options, newChildBuildResults));
}