This commit is contained in:
mem3Dealer
2021-01-10 20:09:46 +03:00
parent 16a737f6ef
commit 99a7969295

View File

@@ -18,14 +18,17 @@ class App extends StatefulWidget {
class AppState extends State<App> with SingleTickerProviderStateMixin {
AnimationController _controller;
String param;
double tm;
@override
void initState() {
super.initState();
param = "beginning";
_controller = AnimationController(
duration: Duration(seconds: 10),
duration: Duration(milliseconds: 10000),
vsync: this,
);
)..addListener(() => contrVal());
}
@override
@@ -43,6 +46,15 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
}
}
contrVal() {
setState(() {
tm = _controller.value;
if (_controller.value >= 0.2) param = 'two seconds';
if (_controller.value >= 0.5) param = "five seconds";
if (_controller.value >= 1) param = "ten seconds";
});
}
@override
Widget build(BuildContext context) {
return Material(
@@ -58,20 +70,28 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
fit: BoxFit.cover,
),
ColorFiltered(
colorFilter:
ColorFilter.mode(Colors.black.withOpacity(0.8), BlendMode.srcOut), // This one will create the magic
colorFilter: ColorFilter.mode(Colors.black.withOpacity(0.8),
BlendMode.srcOut), // This one will create the magic
child: Stack(
fit: StackFit.expand,
children: [
Container(
decoration: BoxDecoration(
color: Colors.black,
backgroundBlendMode: BlendMode.dstOut), // This one will handle background + difference out
backgroundBlendMode: BlendMode
.dstOut), // This one will handle background + difference out
),
MovingHole(controller: _controller)
MovingHole(controller: _controller),
],
),
),
Container(
alignment: Alignment.bottomCenter,
child: Text(
"$param - $tm",
style:
TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
))
],
),
));
@@ -79,66 +99,16 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
}
class MovingHole extends StatelessWidget {
// MovingHole({Key key, this.controller})
// : width = TweenSequence(
// <TweenSequenceItem<double>>[
// TweenSequenceItem<double>(
// tween: Tween<double>(begin: 100, end: 150)
// .chain(CurveTween(curve: Curves.ease)),
// weight: 33.0,
// ),
// TweenSequenceItem<double>(
// tween: Tween<double>(begin: 150, end: 200),
// weight: 33.0,
// ),
// TweenSequenceItem<double>(
// tween: Tween<double>(begin: 200, end: 300)
// .chain(CurveTween(curve: Curves.ease)),
// weight: 33.0,
// ),
// ],
// ).animate(CurvedAnimation(
// parent: controller, curve: Interval(0.0, 1, curve: Curves.linear))),
// height = TweenSequence(
// <TweenSequenceItem<double>>[
// TweenSequenceItem<double>(
// tween: Tween<double>(begin: 100, end: 150)
// .chain(CurveTween(curve: Curves.ease)),
// weight: 40.0,
// ),
// TweenSequenceItem<double>(
// tween: Tween<double>(begin: 150, end: 200),
// weight: 20.0,
// ),
// TweenSequenceItem<double>(
// tween: Tween<double>(begin: 200, end: 300)
// .chain(CurveTween(curve: Curves.ease)),
// weight: 40.0,
// ),
// ],
// ).animate(CurvedAnimation(
// parent: controller,
// curve: Interval(0.0, 1, curve: Curves.fastOutSlowIn))),
// radius = BorderRadiusTween(
// begin: BorderRadius.circular(0.0),
// end: BorderRadius.circular(100.0))
// .animate(CurvedAnimation(
// parent: controller,
// curve: Interval(
// 0.0,
// 1,
// curve: Curves.ease,
// ))),
// alignment = AlignmentTween(
// begin: Alignment.bottomCenter, end: Alignment.topCenter)
// .animate(CurvedAnimation(
// parent: controller,
// curve: Interval(0.0, 1, curve: Curves.ease))),
double timeM(double scene) {
int time = 10;
return scene / time;
}
MovingHole({Key key, this.controller})
: scale1 = Tween<double>(begin: 1.0, end: 0.5).animate(
CurvedAnimation(
parent: controller,
curve: const Interval(0.05, 0.075, curve: Curves.easeOut),
curve: Interval(0.05, 0.075, curve: Curves.easeOut),
),
),
scale2 = Tween<double>(begin: 0.5, end: 1.2).animate(
@@ -151,7 +121,8 @@ class MovingHole extends StatelessWidget {
),
),
),
move1 = Tween<Offset>(begin: Offset(0, 20), end: Offset(-20, 100)).animate(CurvedAnimation(
move1 = Tween<Offset>(begin: Offset(0, 20), end: Offset(-20, 100))
.animate(CurvedAnimation(
parent: controller,
curve: const Interval(
0.0,
@@ -159,7 +130,8 @@ class MovingHole extends StatelessWidget {
curve: Curves.ease,
),
)),
move2 = Tween<Offset>(begin: Offset(50, 100), end: Offset(30, 20)).animate(CurvedAnimation(
move2 = Tween<Offset>(begin: Offset(50, 100), end: Offset(30, 20))
.animate(CurvedAnimation(
parent: controller,
curve: const Interval(
0.9,
@@ -204,25 +176,14 @@ class MovingHole extends StatelessWidget {
decoration: BoxDecoration(
shape: BoxShape.circle,
color: color,
border: Border.all(color: color, style: BorderStyle.solid, width: 4.0 - (2 * controller.value))),
border: Border.all(
color: color,
style: BorderStyle.solid,
width: 4.0 - (2 * controller.value))),
)),
// ),
);
});
}
// Widget build(BuildContext context) {
// return AnimatedBuilder(
// animation: controller,
// builder: (BuildContext context, Widget child) {
// return Container(
// // alignment: alignment.value,
// child: Container(
// width: size.value.width,
// height: size.value.height,
// decoration: BoxDecoration(
// color: Colors.red, borderRadius: BorderRadius.all(Radius.circular(20))),
// ));
// });
// }
}
// создать переменную, листенером слить текущее значение, на поляне в стеке вывести.
// сколько составляет 0.05 от 10 секунд