动画
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ResultNotice extends StatelessWidget {
|
class ResultNotice extends StatefulWidget {
|
||||||
final Color color;
|
final Color color;
|
||||||
final String info;
|
final String info;
|
||||||
|
|
||||||
@@ -10,17 +10,43 @@ class ResultNotice extends StatelessWidget {
|
|||||||
required this.info,
|
required this.info,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ResultNotice> createState() => _ResultNoticeState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ResultNoticeState extends State<ResultNotice> with SingleTickerProviderStateMixin{
|
||||||
|
|
||||||
|
late AnimationController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
controller = AnimationController(vsync: this,duration: const Duration(milliseconds: 200));
|
||||||
|
controller.forward();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant ResultNotice oldWidget) {
|
||||||
|
controller.forward(from: 0);
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
color: color,
|
color: widget.color,
|
||||||
child: Text(
|
child: AnimatedBuilder(
|
||||||
info,
|
animation: controller,
|
||||||
style: TextStyle(
|
builder: (_,child) => Text(
|
||||||
fontSize: 54, color: Colors.white, fontWeight: FontWeight.bold),
|
widget.info,
|
||||||
),
|
style: TextStyle(
|
||||||
));
|
fontSize: 54*(controller.value),
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user