Flutter 自定义手势页面
import 'package:flutter/material.dart';
class GestureUnlockWidget extends StatefulWidget{
GestureWidgetOpts _opts;
GestureWidgetCallBack _callBack;
GestureUnlockWidget(this._opts,this._callBack);
@override
_GestureUnlockWidgetState createState() => _GestureUnlockWidgetState(this._opts,this._callBack);
}
class _GestureUnlockWidgetState extends State<StatefulWidget>{
GestureWidgetOpts _opts;
GestureWidgetCallBack _callBack;
_GestureUnlockWidgetState(this._opts,this._callBack);
List _imgs = [0,1,2,3,4,5,6,7,8];
List _paths = [];
bool _validFlag = true;
bool _canPaint = true;
Offset _offset ;
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final width = size.width;
final height = size.height;
final canvasSize = width > height ? height : width;
final imageSize = canvasSize / 7 ;
final padding = imageSize / 2;
Image getGestureUnlockImage(int idx){
var imagePath = _opts.normalImage;
if(_paths.contains(idx)){
imagePath = _validFlag ? _opts.selectedImage : _opts.errorImage;
}
return Image(
image: AssetImage(imagePath),
height: imageSize,
);
}
Positioned painterGestureUnlockImage(int idx){
double x = padding;
double y = padding;
x += (idx % 3)