Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. class textList extends StatefulWidget {
  2.  
  3. @override
  4. State<StatefulWidget> createState() =>
  5. new _textListState();
  6. }
  7.  
  8. class _textListState extends State<textList>
  9. with TickerProviderStateMixin {
  10.  
  11. List<Widget> items = new List();
  12. Widget lorem = new textClass("Lorem");
  13. Timer timer;
  14.  
  15. @override
  16. void initState() {
  17. super.initState();
  18.  
  19. items.add(new textClass("test"));
  20. items.add(new textClass("test"));
  21.  
  22. timer = new Timer.periodic(new Duration(seconds: 5), (Timer timer) {
  23. setState(() {
  24. items.removeAt(0);
  25. items.add(lorem);
  26. });
  27. });
  28. }
  29.  
  30. @override
  31. void dispose() {
  32. super.dispose();
  33. timer.cancel();
  34. }
  35.  
  36. @override
  37. Widget build(BuildContext context) {
  38. Iterable<Widget> content = ListTile.divideTiles(
  39. context: context, tiles: items).toList();
  40.  
  41. return new Column(
  42. children: content,
  43. );
  44. }
  45. }
  46.  
  47. class textClass extends StatefulWidget {
  48. textClass(this.word);
  49.  
  50. final String word;
  51.  
  52. @override
  53. State<StatefulWidget> createState() =>
  54. new _textClass(word);
  55. }
  56.  
  57. class _textClass extends State<textClass>
  58. with TickerProviderStateMixin {
  59. _textClass(this.word);
  60.  
  61. String word;
  62. Timer timer;
  63.  
  64. @override
  65. void initState() {
  66. super.initState();
  67.  
  68. timer = new Timer.periodic(new Duration(seconds: 2), (Timer timer) {
  69. setState(() {
  70. word += "t";
  71. });
  72. });
  73. }
  74.  
  75. @override
  76. void dispose() {
  77. super.dispose();
  78. timer.cancel();
  79. }
  80.  
  81.  
  82. @override
  83. Widget build(BuildContext context) {
  84. return new Text(word);
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement