Skip to content

Commit c1957d9

Browse files
Format code
1 parent 0e5e288 commit c1957d9

23 files changed

Lines changed: 154 additions & 161 deletions

File tree

native_image_cropper/example/lib/main.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ class _HomeState extends State<_Home> {
7272
builder: (context, snapshot) => switch (snapshot.data) {
7373
null => const LoadingIndicator(),
7474
final bytes => TabBarView(
75-
physics: const NeverScrollableScrollPhysics(),
76-
children: [
77-
DefaultPage(bytes: bytes),
78-
CustomPage(bytes: bytes),
79-
NativePage(bytes: bytes),
80-
],
81-
),
75+
physics: const NeverScrollableScrollPhysics(),
76+
children: [
77+
DefaultPage(bytes: bytes),
78+
CustomPage(bytes: bytes),
79+
NativePage(bytes: bytes),
80+
],
81+
),
8282
},
8383
),
8484
),

native_image_cropper/example/lib/pages/custom.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class _CustomPageState extends State<CustomPage> {
6363
children: [
6464
switch (Platform.operatingSystem) {
6565
'macos' => Expanded(
66-
child: cropPreview,
67-
),
66+
child: cropPreview,
67+
),
6868
_ => cropPreview,
6969
},
7070
Row(

native_image_cropper/example/lib/pages/default.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class _DefaultPageState extends State<DefaultPage> {
5656
children: [
5757
switch (Platform.operatingSystem) {
5858
'macos' => Expanded(
59-
child: cropPreview,
60-
),
59+
child: cropPreview,
60+
),
6161
_ => cropPreview,
6262
},
6363
Row(

native_image_cropper/example/lib/pages/native.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class _NativePageState extends State<NativePage> {
3333
children: [
3434
switch (Platform.operatingSystem) {
3535
'macos' => Expanded(
36-
child: image,
37-
),
36+
child: image,
37+
),
3838
_ => image,
3939
},
4040
const SizedBox(height: 20),
@@ -81,21 +81,21 @@ class _NativePageState extends State<NativePage> {
8181
Future<void> _cropImage(BuildContext context, CropMode mode) async {
8282
final croppedBytes = await switch (mode) {
8383
CropMode.rect => NativeImageCropper.cropRect(
84-
bytes: widget.bytes,
85-
x: 1200,
86-
y: 900,
87-
width: 600,
88-
height: 600,
89-
format: _format,
90-
),
84+
bytes: widget.bytes,
85+
x: 1200,
86+
y: 900,
87+
width: 600,
88+
height: 600,
89+
format: _format,
90+
),
9191
CropMode.oval => NativeImageCropper.cropOval(
92-
bytes: widget.bytes,
93-
x: 1200,
94-
y: 900,
95-
width: 600,
96-
height: 600,
97-
format: _format,
98-
),
92+
bytes: widget.bytes,
93+
x: 1200,
94+
y: 900,
95+
width: 600,
96+
height: 600,
97+
format: _format,
98+
),
9999
};
100100

101101
if (context.mounted) {

native_image_cropper/example/lib/pages/result.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ class _ResultPageState extends State<ResultPage> {
6767

6868
Future<void> _saveImageWeb() async {
6969
final format = widget.format == ImageFormat.jpg ? 'jpeg' : 'png';
70-
final mimeType = widget.format == ImageFormat.jpg
71-
? MimeType.jpeg
72-
: MimeType.png;
70+
final mimeType =
71+
widget.format == ImageFormat.jpg ? MimeType.jpeg : MimeType.png;
7372

7473
await FileSaver.instance.saveFile(
7574
name: MyApp.imageName,

native_image_cropper/example/lib/themes.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ class CustomThemes {
44
const CustomThemes._();
55

66
static ThemeData theme(BuildContext context) => ThemeData(
7-
useMaterial3: false,
8-
colorScheme: ColorScheme.of(context).copyWith(
9-
primary: _green,
10-
secondary: _yellow,
11-
),
12-
bottomSheetTheme: const BottomSheetThemeData(
13-
backgroundColor: Colors.transparent,
14-
),
15-
);
7+
useMaterial3: false,
8+
colorScheme: ColorScheme.of(context).copyWith(
9+
primary: _green,
10+
secondary: _yellow,
11+
),
12+
bottomSheetTheme: const BottomSheetThemeData(
13+
backgroundColor: Colors.transparent,
14+
),
15+
);
1616

1717
static const MaterialColor _green = MaterialColor(
1818
_greenPrimaryValue,

native_image_cropper/lib/src/controller.dart

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ final class CropController {
5050
/// Calculates the crop size based on the relative positions of the
5151
/// [cropRect], [imageRect] and the original [imageSize].
5252
Size get cropSize {
53-
if ((cropRect, imageRect, imageSize) case (
54-
final Rect cropRect,
55-
final Rect imageRect,
56-
final Size imageSize,
57-
)) {
53+
if ((cropRect, imageRect, imageSize)
54+
case (
55+
final Rect cropRect,
56+
final Rect imageRect,
57+
final Size imageSize,
58+
)) {
5859
final width = cropRect.width / imageRect.width * imageSize.width;
5960
final height = cropRect.height / imageRect.height * imageSize.height;
6061
return Size(width, height);
@@ -71,34 +72,35 @@ final class CropController {
7172
/// You can additionally set the [ImageFormat] for compression, defaults to
7273
/// [ImageFormat.jpg].
7374
Future<Uint8List> crop({ImageFormat format = ImageFormat.jpg}) {
74-
if ((cropRect, imageRect, imageSize, bytes) case (
75-
final Rect cropRect,
76-
final Rect imageRect,
77-
final Size imageSize,
78-
final Uint8List bytes,
79-
)) {
75+
if ((cropRect, imageRect, imageSize, bytes)
76+
case (
77+
final Rect cropRect,
78+
final Rect imageRect,
79+
final Size imageSize,
80+
final Uint8List bytes,
81+
)) {
8082
final x = (cropRect.left / imageRect.width * imageSize.width).toInt();
8183
final y = (cropRect.top / imageRect.height * imageSize.height).toInt();
8284
final width = cropSize.width.toInt();
8385
final height = cropSize.height.toInt();
8486

8587
return switch (modeNotifier.value) {
8688
CropMode.oval => NativeImageCropper.cropOval(
87-
bytes: bytes,
88-
x: x,
89-
y: y,
90-
width: width,
91-
height: height,
92-
format: format,
93-
),
89+
bytes: bytes,
90+
x: x,
91+
y: y,
92+
width: width,
93+
height: height,
94+
format: format,
95+
),
9496
CropMode.rect => NativeImageCropper.cropRect(
95-
bytes: bytes,
96-
x: x,
97-
y: y,
98-
width: width,
99-
height: height,
100-
format: format,
101-
),
97+
bytes: bytes,
98+
x: x,
99+
y: y,
100+
width: width,
101+
height: height,
102+
format: format,
103+
),
102104
};
103105
}
104106

native_image_cropper/lib/src/crop_preview/drag_points.dart

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ class _CropDragPoints extends StatelessWidget {
4444
delta: details.delta,
4545
moveSpecificCropCornerFnc: cropUtils.moveTopLeftCorner,
4646
),
47-
child:
48-
dragPointBuilder?.call(
47+
child: dragPointBuilder?.call(
4948
dragPointSize,
5049
CropDragPointPosition.topLeft,
5150
) ??
@@ -61,8 +60,7 @@ class _CropDragPoints extends StatelessWidget {
6160
delta: details.delta,
6261
moveSpecificCropCornerFnc: cropUtils.moveTopRightCorner,
6362
),
64-
child:
65-
dragPointBuilder?.call(
63+
child: dragPointBuilder?.call(
6664
dragPointSize,
6765
CropDragPointPosition.topRight,
6866
) ??
@@ -78,8 +76,7 @@ class _CropDragPoints extends StatelessWidget {
7876
delta: details.delta,
7977
moveSpecificCropCornerFnc: cropUtils.moveBottomLeftCorner,
8078
),
81-
child:
82-
dragPointBuilder?.call(
79+
child: dragPointBuilder?.call(
8380
dragPointSize,
8481
CropDragPointPosition.bottomLeft,
8582
) ??
@@ -95,8 +92,7 @@ class _CropDragPoints extends StatelessWidget {
9592
delta: details.delta,
9693
moveSpecificCropCornerFnc: cropUtils.moveBottomRightCorner,
9794
),
98-
child:
99-
dragPointBuilder?.call(
95+
child: dragPointBuilder?.call(
10096
dragPointSize,
10197
CropDragPointPosition.bottomRight,
10298
) ??
@@ -116,13 +112,13 @@ class _CropDragPoints extends StatelessWidget {
116112
required Offset delta,
117113
Rect? cropRect,
118114
Rect? imageRect,
119-
})
120-
moveSpecificCropCornerFnc,
121-
}) => controller.cropRect = moveSpecificCropCornerFnc(
122-
cropRect: controller.cropRect,
123-
imageRect: controller.imageRectNotifier.value,
124-
delta: delta,
125-
);
115+
}) moveSpecificCropCornerFnc,
116+
}) =>
117+
controller.cropRect = moveSpecificCropCornerFnc(
118+
cropRect: controller.cropRect,
119+
imageRect: controller.imageRectNotifier.value,
120+
delta: delta,
121+
);
126122

127123
@override
128124
void debugFillProperties(DiagnosticPropertiesBuilder properties) {

native_image_cropper/lib/src/crop_preview/image.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ class _CropImageState extends State<_CropImage> {
5555
return GestureDetector(
5656
onPanStart: (details) => _isMovingCropLayer =
5757
_controller.cropRectNotifier.value?.contains(
58-
details.localPosition,
59-
) ??
60-
false,
58+
details.localPosition,
59+
) ??
60+
false,
6161
onPanUpdate: _onMoveCropRectUpdate,
6262
onPanEnd: (_) => _isMovingCropLayer = false,
6363
child: LayoutBuilder(
6464
builder: (context, constraints) {
65-
final availableSpace =
66-
Offset.zero &
65+
final availableSpace = Offset.zero &
6766
Size(constraints.maxWidth, constraints.maxHeight);
6867
final imageRect = widget.cropUtils.computeImageRect(
6968
imageSize: imageSize,
@@ -78,12 +77,12 @@ class _CropImageState extends State<_CropImage> {
7877
imageRect,
7978
);
8079
} else {
81-
_controller.cropRect = widget.cropUtils
82-
.computeCropRectForResizedImageRect(
83-
imageRect: imageRect,
84-
oldImageRect: _controller.imageRect!,
85-
cropRect: cropRect,
86-
);
80+
_controller.cropRect =
81+
widget.cropUtils.computeCropRectForResizedImageRect(
82+
imageRect: imageRect,
83+
oldImageRect: _controller.imageRect!,
84+
cropRect: cropRect,
85+
);
8786
}
8887

8988
_controller.imageRect = imageRect;

native_image_cropper/lib/src/crop_preview/preview.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ part 'image.dart';
1111

1212
/// Type alias for a callback function.
1313
/// Used to build a custom drag point in a [CropPreview].
14-
typedef CropDragPointBuilder =
15-
Widget Function(
16-
double size,
17-
CropDragPointPosition position,
18-
);
14+
typedef CropDragPointBuilder = Widget Function(
15+
double size,
16+
CropDragPointPosition position,
17+
);
1918

2019
/// The [CropPreview] implements a preview screen for image cropping.
2120
/// It allows the user to crop the image using a movable and resizable

0 commit comments

Comments
 (0)