Created
June 6, 2018 15:23
-
-
Save ajaybeniwal/86abde735ad776a873b2eb15f6650f0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'barcontainer.dart'; | |
import 'dart:async'; | |
class BarContainerAnimation extends StatefulWidget { | |
@override | |
_BarContainerAnimationState createState() => | |
new _BarContainerAnimationState(); | |
} | |
class _BarContainerAnimationState extends State<BarContainerAnimation> | |
with TickerProviderStateMixin { | |
AnimationController _controller; | |
@override | |
void initState() { | |
super.initState(); | |
_controller = new AnimationController( | |
duration: const Duration(milliseconds: 2000), vsync: this); | |
_playAnimation(); | |
} | |
@override | |
void dispose() { | |
_controller.dispose(); | |
super.dispose(); | |
} | |
Future<Null> _playAnimation() async { | |
try { | |
await _controller.repeat().orCancel; | |
} on TickerCanceled { | |
// the animation got canceled, probably because we were disposed | |
} | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new BarContainer(controller: _controller.view); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment