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
| class BarChartApplication extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Padding( | |
| padding: const EdgeInsets.all(20.0), | |
| child: Row( | |
| mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
| children: <Widget>[ | |
| Bar(0.3, "2013"), | |
| Bar(0.5, "2014"), |
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
| class Bar extends StatelessWidget { | |
| // ... | |
| @override | |
| Widget build(BuildContext context) { | |
| return ControlledAnimation( | |
| duration: Duration(milliseconds: (height * _baseDurationMs).round()), | |
| tween: Tween(begin: 0.0, end: height), | |
| builder: (context, animatedHeight) { | |
| return Column( |
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
| class Bar extends StatelessWidget { | |
| final double height; | |
| final String label; | |
| final int _baseDurationMs = 1000; | |
| final double _maxElementHeight = 100; | |
| Bar(this.height, this.label); | |
| @override |
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
| var _dataIsLoaded = false; | |
| _loadData() { | |
| // Simulate HTTP Request | |
| _dataIsLoaded = false; | |
| Future.delayed(Duration(seconds: 4)).then((_) => _dataIsLoaded = true); | |
| controller.addTasks([ | |
| FromToTask( | |
| duration: Duration(milliseconds: 700), |
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
| @override | |
| Widget build(BuildContext context) { | |
| return Column( | |
| mainAxisAlignment: MainAxisAlignment.start, | |
| crossAxisAlignment: CrossAxisAlignment.center, | |
| children: <Widget>[_progressIndicator(), _requestButton()], | |
| ); | |
| } | |
| var _showCircularProgressIndicator = false; |
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
| class ProgressIndicatorAnimation extends StatefulWidget { | |
| @override | |
| _ProgressIndicatorAnimationState createState() => | |
| _ProgressIndicatorAnimationState(); | |
| } | |
| class _ProgressIndicatorAnimationState extends State<ProgressIndicatorAnimation> | |
| with AnimationControllerMixin { | |
| Animation tween; |
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
| // Animate forward (1s) | |
| controller | |
| .addTask(FromToTask(duration: Duration(seconds: 1), to: 1.0)); | |
| // Animate reverse (0,5s) | |
| controller | |
| .addTask(FromToTask(duration: Duration(milliseconds: 500), to: 0.0)); | |
| // Clear queue (stop all running tasks) and loop forever | |
| controller |
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
| class _WidgetWithAnimationState extends State<WidgetWithAnimation> | |
| with AnimationControllerMixin { | |
| Animation<double> width; | |
| @override | |
| void initState() { | |
| width = Tween(begin: 100.0, end: 200.0).animate(controller); | |
| controller.addTask(FromToTask(duration: Duration(seconds: 1), to: 1.0)); | |
| super.initState(); | |
| } |
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
| class _WidgetWithAnimationState /* ... */ { | |
| AnimationControllerX controller; // change here | |
| // ... | |
| @override | |
| void initState() { | |
| controller = AnimationControllerX(vsync: this); // change here | |
| // ... | |
| } | |
| // ... | |
| } |
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
| class _WidgetWithAnimationState extends State<WidgetWithAnimation> | |
| with SingleTickerProviderStateMixin { | |
| AnimationController controller; | |
| Animation<double> width; | |
| @override | |
| void initState() { | |
| controller = AnimationController( | |
| vsync: this, | |
| duration: Duration(seconds: 1), |