fit property
Fit
get
fit
Controls how the artboard is scaled and positioned within its bounds.
The fit mode determines how the artboard's dimensions are mapped to the widget's dimensions:
- Fit.layout - Resize artboard to match widget size. Used with Rive's layout system.
- Fit.contain - Scale to fit while maintaining aspect ratio
- Fit.cover - Scale to cover while maintaining aspect ratio
- Fit.fill - Stretch to fill the bounds
- Fit.fitWidth - Scale to fit width while maintaining aspect ratio
- Fit.fitHeight - Scale to fit height while maintaining aspect ratio
- Fit.none - No scaling applied
- Fit.scaleDown - Scale down to fit if needed
When using Fit.layout, the artboard dimensions are scaled by layoutScaleFactor to determine the final size.
Implementation
Fit get fit => _fit;
set
fit
(Fit value)
Implementation
set fit(Fit value) {
if (_fit == value) return;
if (value == Fit.layout) {
_resizeArtboard();
} else if (_fit == Fit.layout) {
// Previous fit was Layout, we need to reset the artboard size to default
artboard?.resetArtboardSize();
}
_fit = value;
notifyListeners();
}