mainImageView method
Implementation
RawGestureDetector mainImageView(BuildContext context) {
return RawGestureDetector(
behavior: HitTestBehavior.opaque,
gestures: <Type, GestureRecognizerFactory>{
SingleGestureRecognizer:
GestureRecognizerFactoryWithHandlers<SingleGestureRecognizer>(
() => SingleGestureRecognizer(debugOwner: this),
(instance) {
instance.onStart = (pointerEvent) {
_startNewPath(pointerEvent.localPosition);
};
instance.onUpdate = (pointerEvent) {
_addPointToPath(pointerEvent.localPosition);
};
instance.onEnd = (pointerEvent) {
if (_paths.isNotEmpty && _paths.last.isNotEmpty) {
// Duplicate the last point in the current path
_paths.last.add(_paths.last.last);
}
};
}),
},
child: Container(
height:widget.height ?? MediaQuery.of(context).size.height/2,
width: widget.width ?? MediaQuery.of(context).size.width,
margin: widget.margin ?? EdgeInsets.symmetric(vertical: MediaQuery.of(context).size.height/4,horizontal: 15),
decoration: widget.decoration ?? BoxDecoration(
border: Border.all(color: Colors.black, width: 2)),
child: RepaintBoundary(
key: _globalKey,
child: CustomPaint(
size: Size(
MediaQuery
.of(context)
.size
.width,
MediaQuery
.of(context)
.size
.height,
),
painter: unColoredImage != null && coloredImage != null
? ImageMaskingPainter(
paths: _paths,
coloredImage: coloredImage!,
unColoredImage: unColoredImage!)
: null,
),
),
),
);
}