fit method

void fit(
  1. double width,
  2. double height,
  3. Fit fit
)

This parameter enables you to fit the given image properly within the specified height and width. You need to provide values for the height, width and fit parameters. The two available values for the fit parameter are bounds and crop. fit accepts optional parameters width, height of type int and fir of type Fit

For more details, Read documentation: https://www.contentstack.com/docs/developers/apis/image-delivery-api/#fit-mode

Example:

final stack = contentstack.Stack(apiKey, deliveryToken, environment);
final imageTransformation = stack.imageTransform(imageUrl);
final response = await imageTransformation.
                 fitBy(  250,  250, Fit.crop).fetch();

Implementation

void fit(double width, double height, Fit fit) {
  if (width != null) {
    query.append('width', width.toString());
  }
  if (height != null) {
    query.append('height', height.toString());
  }
  if (fit != null) {
    //enum Fit { bounds, crop }
    fit.when(bounds: (value) {
      query.append('fit', 'bounds');
    }, crop: (value) {
      query.append('fit', 'crop');
    });
  }
}