CropController constructor

CropController({
  1. double? aspectRatio,
  2. Rect defaultCrop = const Rect.fromLTWH(0, 0, 1, 1),
})

A controller for a CropImage widget.

You can provide the required aspectRatio and the initial defaultCrop. If aspectRatio is specified, the defaultCrop rect will be adjusted automatically.

Remember to dispose of the CropController when it's no longer needed. This will ensure we discard any resources used by the object.

Implementation

CropController({
  double? aspectRatio,
  Rect defaultCrop = const Rect.fromLTWH(0, 0, 1, 1),
})  : assert(aspectRatio != 0, 'aspectRatio cannot be zero'),
      assert(defaultCrop.left >= 0 && defaultCrop.left <= 1,
          'left should be 0..1'),
      assert(defaultCrop.right >= 0 && defaultCrop.right <= 1,
          'right should be 0..1'),
      assert(
          defaultCrop.top >= 0 && defaultCrop.top <= 1, 'top should be 0..1'),
      assert(defaultCrop.bottom >= 0 && defaultCrop.bottom <= 1,
          'bottom should be 0..1'),
      assert(defaultCrop.left < defaultCrop.right,
          'left must be less than right'),
      assert(defaultCrop.top < defaultCrop.bottom,
          'top must be less than bottom'),
      super(_CropControllerValue(aspectRatio, defaultCrop));