大佬教程收集整理的这篇文章主要介绍了dart – Flutter – 键入文本动画,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
import 'package:Flutter/material.dart'; void main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter Demo',theme: new ThemeData( pri@R_673_11035@Color: const color.fromARGB(255,199,0),accentColor: const color.fromARGB(255,222,233,226),brightness: Brightness.dark,canvasColor: Colors.black,),home: new MyHomePage(),debugShowcheckedModeBAnner: false,); } } class MyHomePage extends StatefulWidget { @override State createState() => new MyHomePageState(); } class MyHomePageState extends State<MyHomePage> with TickerProviderStatemixin { Animation<int> _characterCount; int _StringIndex; static const List<String> _kStrings = const <String>[ 'Call trans opt: received. 2-19-98 13:24:18 REC:Log>','Trace program running.','[312]555-0690',]; String get _currentString => _kStrings[_StringIndex % _kStrings.length]; @override Widget build(BuildContext context) { ThemeData theme = Theme.of(context); TextStyle textStyle = theme.textTheme.title.copyWith( fontFamily: 'Courier New',color: theme.pri@R_673_11035@Color,); return new Scaffold( floaTingActionButton: new FloaTingActionButton( child: new Icon(Icons.navigate_next),onPressed: () async { AnimationController controller = new AnimationController( duration: const Duration(milliseconds: 4000),vsync: this,); setState(() { _StringIndex = _StringIndex == null ? 0 : _StringIndex + 1; _characterCount = new StepTween(begin: 0,end: _currentString.length) .animate(new CurvedAnimation(parent: controller,curve: Curves.easeIn)); }); await controller.forWARD(); controller.dispose(); },body: new Container( margin: new EdgeInsets.symmetric(vertical: 50.0,horizontal: 10.0),child: _characterCount == null ? null : new AnimatedBuilder( animation: _characterCount,builder: (BuildContext context,Widget child) { String text = _currentString.subString(0,_characterCount.value); return new Text(text,style: textStylE); },); } }
如果您计划大量使用此动画文本小部件,则可以使用AnimatedWidget将其重构为单独的类.
以上是大佬教程为你收集整理的dart – Flutter – 键入文本动画全部内容,希望文章能够帮你解决dart – Flutter – 键入文本动画所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。