resolveSize static method
- required BoxConstraints constraints,
- required double fallbackWidth,
- required double fallbackHeight,
- double? parentWidth,
- double? parentHeight,
- double? contentHeight,
Resolves the platform view's size from the parent's constraints and, when self sizing, the last reported content height. The fallbacks apply while a dimension is unbounded and unmeasured.
Implementation
@visibleForTesting
static Size resolveSize({
required BoxConstraints constraints,
required double fallbackWidth,
required double fallbackHeight,
double? parentWidth,
double? parentHeight,
double? contentHeight,
}) {
final width = parentWidth ??
(constraints.hasBoundedWidth ? constraints.maxWidth : fallbackWidth);
// A report at or below the floor means "could not resolve", not "empty";
// gone content is handled by the availability check, so stay visible.
final measured = (contentHeight != null && contentHeight > _minContentHeight)
? contentHeight
: null;
// Until a usable measurement arrives, take the available space so native has
// room to lay out; whatever the view does not need is returned on report.
final height = parentHeight ??
(constraints.hasBoundedHeight
? constraints.maxHeight
: (measured ?? fallbackHeight));
return Size(width, height);
}