smth
This commit is contained in:
123
lib/main.dart
123
lib/main.dart
@@ -18,14 +18,17 @@ class App extends StatefulWidget {
|
|||||||
|
|
||||||
class AppState extends State<App> with SingleTickerProviderStateMixin {
|
class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||||
AnimationController _controller;
|
AnimationController _controller;
|
||||||
|
String param;
|
||||||
|
double tm;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
param = "beginning";
|
||||||
_controller = AnimationController(
|
_controller = AnimationController(
|
||||||
duration: Duration(seconds: 10),
|
duration: Duration(milliseconds: 10000),
|
||||||
vsync: this,
|
vsync: this,
|
||||||
);
|
)..addListener(() => contrVal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Material(
|
return Material(
|
||||||
@@ -58,20 +70,28 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
|||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
ColorFiltered(
|
ColorFiltered(
|
||||||
colorFilter:
|
colorFilter: ColorFilter.mode(Colors.black.withOpacity(0.8),
|
||||||
ColorFilter.mode(Colors.black.withOpacity(0.8), BlendMode.srcOut), // This one will create the magic
|
BlendMode.srcOut), // This one will create the magic
|
||||||
child: Stack(
|
child: Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.black,
|
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 {
|
class MovingHole extends StatelessWidget {
|
||||||
// MovingHole({Key key, this.controller})
|
double timeM(double scene) {
|
||||||
// : width = TweenSequence(
|
int time = 10;
|
||||||
// <TweenSequenceItem<double>>[
|
return scene / time;
|
||||||
// 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))),
|
|
||||||
MovingHole({Key key, this.controller})
|
MovingHole({Key key, this.controller})
|
||||||
: scale1 = Tween<double>(begin: 1.0, end: 0.5).animate(
|
: scale1 = Tween<double>(begin: 1.0, end: 0.5).animate(
|
||||||
CurvedAnimation(
|
CurvedAnimation(
|
||||||
parent: controller,
|
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(
|
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,
|
parent: controller,
|
||||||
curve: const Interval(
|
curve: const Interval(
|
||||||
0.0,
|
0.0,
|
||||||
@@ -159,7 +130,8 @@ class MovingHole extends StatelessWidget {
|
|||||||
curve: Curves.ease,
|
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,
|
parent: controller,
|
||||||
curve: const Interval(
|
curve: const Interval(
|
||||||
0.9,
|
0.9,
|
||||||
@@ -204,25 +176,14 @@ class MovingHole extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: color,
|
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 секунд
|
||||||
|
|||||||
Reference in New Issue
Block a user