Line data Source code
1 14 : enum CropType {
2 : top,
3 : bottom,
4 : left,
5 : right,
6 : center,
7 : }
8 :
9 : extension _CropX on CropType {
10 2 : String? get name => {
11 : CropType.top: 'top',
12 : CropType.bottom: 'bottom',
13 : CropType.left: 'left',
14 : CropType.right: 'right',
15 : CropType.center: 'center',
16 1 : }[this];
17 : }
18 :
19 : ///
20 : class Crop {
21 : ///
22 2 : const Crop(
23 : this._width,
24 : this._height, {
25 : List<CropType> types = const [CropType.center],
26 2 : }) : assert(_width > 0, 'Width should be a positive number'),
27 2 : assert(_height > 0, 'Height should be a positive number'),
28 : _types = types;
29 :
30 : final int _width;
31 : final int _height;
32 : final List<CropType> _types;
33 :
34 : ///
35 2 : Map<String, Object> get params => <String, Object>{
36 5 : 'crop': _types.map((it) => it.name).join(','),
37 1 : 'w': _width,
38 1 : 'h': _height,
39 : };
40 : }
|