You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using info from Resetting the Matrix#8, I got the matrix to reset correcting when using CustomPaint (basically the same code as the example with CustomPaint). But I have no idea why it is working. I seem to have replaced notifier.value = m, with notifier.value = matrix; when normal zoom, offset and rotation.
It seems to work, but I do not understand. Is it possible my code will give memory leaks or anything? Is it the best way for CustomPaint?
My Code:
class _CustomPainterDemoState extends State {
Matrix4 matrix = Matrix4.identity();
ValueNotifier notifier;
bool resetMatrix = false;
@OverRide
void initState() {
super.initState();
notifier = ValueNotifier(matrix);
.....
in the build
body: MatrixGestureDetector(
onMatrixUpdate: (m, tm, sm, rm) {
if(resetMatrix) {
matrix = MatrixGestureDetector.compose(matrix, tm, sm, rm);
//above appears to reset all matrices
}
notifier.value = matrix; //original code had notifier.value = m
},
I then have child: CustomPaint, exactly like the example
At the bottom, I have a floating Action Button to reset the screen
floatingActionButton: FloatingActionButton(
onPressed:(){
setState(() {
matrix = Matrix4.identity();
notifier = ValueNotifier(matrix);
resetMatrix = true;
});
}
),
The text was updated successfully, but these errors were encountered:
Using info from Resetting the Matrix#8, I got the matrix to reset correcting when using CustomPaint (basically the same code as the example with CustomPaint). But I have no idea why it is working. I seem to have replaced notifier.value = m, with notifier.value = matrix; when normal zoom, offset and rotation.
It seems to work, but I do not understand. Is it possible my code will give memory leaks or anything? Is it the best way for CustomPaint?
My Code:
class _CustomPainterDemoState extends State {
Matrix4 matrix = Matrix4.identity();
ValueNotifier notifier;
bool resetMatrix = false;
@OverRide
void initState() {
super.initState();
notifier = ValueNotifier(matrix);
.....
in the build
body: MatrixGestureDetector(
onMatrixUpdate: (m, tm, sm, rm) {
if(resetMatrix) {
matrix = MatrixGestureDetector.compose(matrix, tm, sm, rm);
//above appears to reset all matrices
}
notifier.value = matrix; //original code had notifier.value = m
},
I then have child: CustomPaint, exactly like the example
At the bottom, I have a floating Action Button to reset the screen
floatingActionButton: FloatingActionButton(
onPressed:(){
setState(() {
matrix = Matrix4.identity();
notifier = ValueNotifier(matrix);
resetMatrix = true;
});
}
),
The text was updated successfully, but these errors were encountered: