paintBackground method
Implementation
void paintBackground(
PaintingContext context, Offset offset, EdgeInsets? padding) {
CSSBoxDecoration? decoration = renderStyle.decoration;
DecorationPosition decorationPosition = renderStyle.decorationPosition;
ImageConfiguration imageConfiguration = renderStyle.imageConfiguration;
if (decoration == null) return;
_painter ??= BoxDecorationPainter(
padding, renderStyle, markNeedsPaint);
final ImageConfiguration filledConfiguration =
imageConfiguration.copyWith(size: size);
if (decorationPosition == DecorationPosition.background) {
int? debugSaveCount;
assert(() {
debugSaveCount = context.canvas.getSaveCount();
return true;
}());
_painter!.paintBackground(context.canvas, offset, filledConfiguration);
assert(() {
if (debugSaveCount != context.canvas.getSaveCount()) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary(
'${decoration.runtimeType} painter had mismatching save and restore calls.'),
ErrorDescription(
'Before painting the decoration, the canvas save count was $debugSaveCount. '
'After painting it, the canvas save count was ${context.canvas.getSaveCount()}. '
'Every call to save() or saveLayer() must be matched by a call to restore().'),
DiagnosticsProperty<Decoration>('The decoration was', decoration,
style: DiagnosticsTreeStyle.errorProperty),
DiagnosticsProperty<BoxPainter>('The painter was', _painter,
style: DiagnosticsTreeStyle.errorProperty),
]);
}
return true;
}());
if (decoration.isComplex) context.setIsComplexHint();
}
if (decorationPosition == DecorationPosition.foreground) {
_painter!.paint(context.canvas, offset, filledConfiguration);
if (decoration.isComplex) context.setIsComplexHint();
}
}