scheduleBuildFor method
Adds an element to the dirty elements list so that it will be rebuilt when WidgetsBinding.drawFrame calls buildScope.
Implementation
void scheduleBuildFor(Element element) {
assert(element != null);
assert(element.owner == this);
assert(() {
if (debugPrintScheduleBuildForStacks)
debugPrintStack(label: 'scheduleBuildFor() called for $element${_dirtyElements.contains(element) ? " (ALREADY IN LIST)" : ""}');
if (!element.dirty) {
throw FlutterError(
'scheduleBuildFor() called for a widget that is not marked as dirty.\n'
'The method was called for the following element:\n'
' $element\n'
'This element is not current marked as dirty. Make sure to set the dirty flag before '
'calling scheduleBuildFor().\n'
'If you did not attempt to call scheduleBuildFor() yourself, then this probably '
'indicates a bug in the widgets framework. Please report it: '
'https://github.com/flutter/flutter/issues/new?template=BUG.md'
);
}
return true;
}());
if (element._inDirtyList) {
assert(() {
if (debugPrintScheduleBuildForStacks)
debugPrintStack(label: 'BuildOwner.scheduleBuildFor() called; _dirtyElementsNeedsResorting was $_dirtyElementsNeedsResorting (now true); dirty list is: $_dirtyElements');
if (!_debugIsInBuildScope) {
throw FlutterError(
'BuildOwner.scheduleBuildFor() called inappropriately.\n'
'The BuildOwner.scheduleBuildFor() method should only be called while the '
'buildScope() method is actively rebuilding the widget tree.'
);
}
return true;
}());
_dirtyElementsNeedsResorting = true;
return;
}
if (!_scheduledFlushDirtyElements && onBuildScheduled != null) {
_scheduledFlushDirtyElements = true;
onBuildScheduled();
}
_dirtyElements.add(element);
element._inDirtyList = true;
assert(() {
if (debugPrintScheduleBuildForStacks)
debugPrint('...dirty list is now: $_dirtyElements');
return true;
}());
}