title | description | type |
---|---|---|
AnimatedDefaultTextStyle |
控件介绍 |
widgets |
TextStyle属性动画,用法如下:
class AnimationDemo extends StatefulWidget {
@override
State<StatefulWidget> createState() => _AnimationDemo();
}
class _AnimationDemo extends State<AnimationDemo>
with SingleTickerProviderStateMixin {
TextStyle _style;
@override
void initState() {
_style=TextStyle(color: Colors.blue, fontSize: 14);
super.initState();
}
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
SizedBox(height: 200,),
AnimatedDefaultTextStyle(
style: _style,
duration: Duration(seconds: 2),
child: Text('老孟'),
),
SizedBox(height: 100,),
RaisedButton(
onPressed: (){
setState(() {
_style = TextStyle(color: Colors.red, fontSize: 24);
});
},
)
],
);
}
}
效果如下: