Add All the files from the touchpad_demonstrator Flutter App which can be build for Android and iOS
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'finger_painter.dart';
|
||||
class Finger extends StatefulWidget {
|
||||
@override
|
||||
_FingerState createState() => _FingerState();
|
||||
}
|
||||
|
||||
class _FingerState extends State<Finger> with SingleTickerProviderStateMixin {
|
||||
double _fraction = 0.0;
|
||||
Animation<double> animation;
|
||||
int animationDuration = 10000;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
var controller = AnimationController(
|
||||
duration: Duration(milliseconds: animationDuration), vsync: this);
|
||||
animation = Tween(begin: 0.0, end: 1.0).animate(controller)
|
||||
..addListener((){
|
||||
setState(() {
|
||||
//print(animation.value);
|
||||
_fraction = animation.value;
|
||||
});
|
||||
print(animation.value);
|
||||
});
|
||||
controller.forward();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomPaint(painter: FingerPainter(_fraction));
|
||||
}
|
||||
}
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FingerPainter extends CustomPainter {
|
||||
Paint _paint;
|
||||
double _fraction;
|
||||
|
||||
FingerPainter(this._fraction) {
|
||||
_paint = Paint()
|
||||
..color = Colors.blue
|
||||
..strokeWidth = 10.0
|
||||
..strokeCap = StrokeCap.round;
|
||||
}
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
print('paint $_fraction');
|
||||
canvas.drawLine(Offset(0.0, 0.0),
|
||||
Offset(size.width * _fraction, size.height * _fraction), _paint);
|
||||
canvas.drawLine(Offset(size.width, 0.0),
|
||||
Offset(size.width - size.width * _fraction, size.height * _fraction), _paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(FingerPainter oldDelegate) {
|
||||
return oldDelegate._fraction != _fraction;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user