From eb702ae07caa0c775b511dc1894e84cbce138aff Mon Sep 17 00:00:00 2001 From: Erick Zanardo Date: Mon, 25 May 2020 12:20:58 -0300 Subject: [PATCH] Linting --- doc/examples/widgets/lib/main.dart | 31 ++++++++++++------------- lib/widgets/flame_animation_widget.dart | 30 +++++++++++------------- lib/widgets/flame_sprite_widget.dart | 3 ++- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/doc/examples/widgets/lib/main.dart b/doc/examples/widgets/lib/main.dart index 62604158c..915a3e706 100644 --- a/doc/examples/widgets/lib/main.dart +++ b/doc/examples/widgets/lib/main.dart @@ -87,24 +87,23 @@ void main() async { rows: 1, ); final _animation = _animationSpriteSheet.createAnimation( - 0, - stepTime: 0.2, - to: 3, - loop: true, + 0, + stepTime: 0.2, + to: 3, + loop: true, ); - dashbook.storiesOf('FlameAnimationWidget').decorator(CenterDecorator()) - .add( - 'default', - (ctx) => Container( - width: ctx.numberProperty('container width', 400), - height: ctx.numberProperty('container height', 200), - padding: const EdgeInsets.all(20), - child: FlameAnimationWidget( - animation: _animation, - play: ctx.boolProperty('playing', true), - center: ctx.boolProperty('center', true), - ), + dashbook.storiesOf('FlameAnimationWidget').decorator(CenterDecorator()).add( + 'default', + (ctx) => Container( + width: ctx.numberProperty('container width', 400), + height: ctx.numberProperty('container height', 200), + padding: const EdgeInsets.all(20), + child: FlameAnimationWidget( + animation: _animation, + play: ctx.boolProperty('playing', true), + center: ctx.boolProperty('center', true), ), + ), ); runApp(dashbook); diff --git a/lib/widgets/flame_animation_widget.dart b/lib/widgets/flame_animation_widget.dart index 4dbebd11a..f139d0ed8 100644 --- a/lib/widgets/flame_animation_widget.dart +++ b/lib/widgets/flame_animation_widget.dart @@ -14,14 +14,14 @@ class FlameAnimationWidget extends StatefulWidget { this.animation, this.play = true, this.center = false, - }): assert(animation.loaded(), 'Animation must be loaded'); + }) : assert(animation.loaded(), 'Animation must be loaded'); @override State createState() => _FlameAnimationWidget(); } -class _FlameAnimationWidget extends State with SingleTickerProviderStateMixin { - +class _FlameAnimationWidget extends State + with SingleTickerProviderStateMixin { AnimationController _controller; int _lastUpdated; @@ -39,19 +39,17 @@ class _FlameAnimationWidget extends State with SingleTicke void initState() { super.initState(); - _controller = AnimationController( - vsync: this - ) - ..addListener(() { - final now = DateTime.now().millisecond; + _controller = AnimationController(vsync: this) + ..addListener(() { + final now = DateTime.now().millisecond; - final dt = max(0, (now - _lastUpdated) / 1000); - widget.animation.update(dt); + final dt = max(0, (now - _lastUpdated) / 1000); + widget.animation.update(dt); - setState(() { - _lastUpdated = now; + setState(() { + _lastUpdated = now; + }); }); - }); widget.animation.onCompleteAnimation = _pauseAnimation; @@ -66,8 +64,7 @@ class _FlameAnimationWidget extends State with SingleTicke _lastUpdated = DateTime.now().millisecond; _controller.repeat( // -/+ 60 fps - period: Duration(milliseconds: 16) - ); + period: Duration(milliseconds: 16)); }); } @@ -85,6 +82,7 @@ class _FlameAnimationWidget extends State with SingleTicke @override Widget build(ctx) { - return FlameSpriteWidget(sprite: widget.animation.getSprite(), center: widget.center); + return FlameSpriteWidget( + sprite: widget.animation.getSprite(), center: widget.center); } } diff --git a/lib/widgets/flame_sprite_widget.dart b/lib/widgets/flame_sprite_widget.dart index 5c911e56b..41e359ae5 100644 --- a/lib/widgets/flame_sprite_widget.dart +++ b/lib/widgets/flame_sprite_widget.dart @@ -28,7 +28,8 @@ class _FlameSpritePainer extends CustomPainter { _FlameSpritePainer(this._sprite, this._center); @override - bool shouldRepaint(_FlameSpritePainer old) => old._sprite != _sprite || old._center != _center; + bool shouldRepaint(_FlameSpritePainer old) => + old._sprite != _sprite || old._center != _center; @override void paint(Canvas canvas, Size size) {