Skip to content

Commit 4e166f4

Browse files
Merge pull request #2 from flutter-clutter/resize_crop_area
Implement possibility to resize the crop area
2 parents 7a4b6c7 + a4228b3 commit 4e166f4

8 files changed

+441
-152
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A Flutter plugin enabling the user to detect edges of a given image. It returns
55
## Demo
66

77
<p align="center">
8-
<img src="https://www.flutterclutter.dev/wp-content/uploads/2020/09/flutter-edge-detection-animation.gif" height=600>
8+
<img src="https://www.flutterclutter.dev/wp-content/uploads/2020/09/flutter-edge-detection-drag-animation.gif" height=600>
99
</p>
1010

1111
## Try out

example/lib/edge_detection_preview.dart

-149
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import 'package:flutter/material.dart';
2+
3+
class AnimatedTouchBubblePart extends StatefulWidget {
4+
AnimatedTouchBubblePart({this.dragging, this.size});
5+
6+
final bool dragging;
7+
final double size;
8+
9+
@override
10+
_AnimatedTouchBubblePartState createState() => _AnimatedTouchBubblePartState();
11+
}
12+
13+
class _AnimatedTouchBubblePartState extends State<AnimatedTouchBubblePart> with SingleTickerProviderStateMixin {
14+
AnimationController _controller;
15+
Animation<Color> _colorAnimation;
16+
Animation<double> _sizeAnimation;
17+
18+
@override
19+
void didChangeDependencies() {
20+
_controller = new AnimationController(
21+
duration: const Duration(milliseconds: 1000),
22+
vsync: this,
23+
);
24+
25+
_sizeAnimation = Tween<double>(
26+
begin: 0.5,
27+
end: 1.0
28+
).animate(_controller);
29+
30+
_colorAnimation = ColorTween(
31+
begin: Theme.of(context).accentColor.withOpacity(0.5),
32+
end: Theme.of(context).accentColor.withOpacity(0.0)
33+
).animate(
34+
CurvedAnimation(
35+
parent: _controller,
36+
curve: Interval(0.5, 1.0)
37+
)
38+
);
39+
40+
_controller.repeat();
41+
super.didChangeDependencies();
42+
}
43+
44+
@override
45+
void dispose() {
46+
_controller.dispose();
47+
super.dispose();
48+
}
49+
50+
@override
51+
Widget build(BuildContext context) {
52+
return Stack(
53+
children: [
54+
Center(
55+
child: Container(
56+
width: widget.dragging ? widget.size : widget.size / 2,
57+
height: widget.dragging ? widget.size : widget.size / 2,
58+
decoration: BoxDecoration(
59+
color: Theme.of(context).accentColor.withOpacity(0.5),
60+
borderRadius: widget.dragging ? BorderRadius.circular(widget.size) : BorderRadius.circular(widget.size / 4)
61+
)
62+
)
63+
),
64+
AnimatedBuilder(
65+
builder: (BuildContext context, Widget child) {
66+
return Center(
67+
child: Container(
68+
width: widget.dragging ? 0 : widget.size * _sizeAnimation.value,
69+
height: widget.dragging ? 0 : widget.size * _sizeAnimation.value,
70+
decoration: BoxDecoration(
71+
border: Border.all(
72+
color: _colorAnimation.value,
73+
width: widget.size / 20
74+
),
75+
borderRadius: widget.dragging ? BorderRadius.zero : BorderRadius.circular(widget.size * _sizeAnimation.value / 2)
76+
)
77+
)
78+
);
79+
},
80+
animation: _controller
81+
)
82+
],
83+
);
84+
}
85+
}

0 commit comments

Comments
 (0)