books
This commit is contained in:
45
packages/idraw/lib/p14/touch_info.dart
Normal file
45
packages/idraw/lib/p14/touch_info.dart
Normal file
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020/11/4
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明:
|
||||
|
||||
class TouchInfo extends ChangeNotifier {
|
||||
List<Offset> _points = [];
|
||||
int _selectIndex = -1;
|
||||
|
||||
void setPoints(List<Offset> points) {
|
||||
_points = points;
|
||||
}
|
||||
|
||||
|
||||
int get selectIndex => _selectIndex;
|
||||
|
||||
List<Offset> get points => _points;
|
||||
|
||||
set selectIndex(int value) {
|
||||
assert(value != null);
|
||||
if (_selectIndex == value) return;
|
||||
|
||||
_selectIndex = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void addPoint(Offset point) {
|
||||
points.add(point);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void updatePoint(int index, Offset point) {
|
||||
points[index] = point;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_points.clear();
|
||||
_selectIndex = -1;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Offset? get selectPoint => _selectIndex == -1 ? null : _points[_selectIndex];
|
||||
}
|
||||
Reference in New Issue
Block a user