diff --git a/doc/examples/widgets/lib/main.dart b/doc/examples/widgets/lib/main.dart index 94a67158d..1247861d1 100644 --- a/doc/examples/widgets/lib/main.dart +++ b/doc/examples/widgets/lib/main.dart @@ -12,7 +12,12 @@ void main() async { final nineTileBoxImage = await Flame.images.load('nine_tile_box.png'); await Flame.images.load('buttons.png'); - final _buttons = SpriteSheet(imageName: 'buttons.png', textureHeight: 20, textureWidth: 60, columns: 1, rows: 2); + final _buttons = SpriteSheet( + imageName: 'buttons.png', + textureHeight: 20, + textureWidth: 60, + columns: 1, + rows: 2); final dashbook = Dashbook(); @@ -37,16 +42,19 @@ void main() async { )); dashbook.storiesOf('SpriteButton').decorator(CenterDecorator()).add( - 'default', - (ctx) => Container(padding: const EdgeInsets.all(20), child: SpriteButton( - onPressed: () { - print('Pressed'); - }, - label: const Text('Sprite Button', style: const TextStyle(color: const Color(0xFF5D275D))), - sprite: _buttons.getSprite(0, 0), - pressedSprite: _buttons.getSprite(1, 0), - )), - ); + 'default', + (ctx) => Container( + padding: const EdgeInsets.all(20), + child: SpriteButton( + onPressed: () { + print('Pressed'); + }, + label: const Text('Sprite Button', + style: const TextStyle(color: const Color(0xFF5D275D))), + sprite: _buttons.getSprite(0, 0), + pressedSprite: _buttons.getSprite(1, 0), + )), + ); runApp(dashbook); } diff --git a/lib/widgets/sprite_button.dart b/lib/widgets/sprite_button.dart index 73042d806..5c1df6e12 100644 --- a/lib/widgets/sprite_button.dart +++ b/lib/widgets/sprite_button.dart @@ -15,7 +15,6 @@ class SpriteButton extends StatefulWidget { @required this.label, @required this.sprite, @required this.pressedSprite, - this.width, this.height, }); @@ -33,31 +32,32 @@ class _ButtonState extends State { final height = widget.height ?? 50; return GestureDetector( - onTapDown: (_) { - setState(() { - _pressed = true; - }); - }, - onTapUp: (_) { - setState(() { - _pressed = false; - }); + onTapDown: (_) { + setState(() { + _pressed = true; + }); + }, + onTapUp: (_) { + setState(() { + _pressed = false; + }); - widget.onPressed?.call(); - }, - child: Container( - width: width, - height: height, - child: CustomPaint( - painter: _ButtonPainer(_pressed ? widget.pressedSprite : widget.sprite), - child: Center( - child: Container( - padding: _pressed ? const EdgeInsets.only(top: 5) : null, - child: widget.label, - ), - ), + widget.onPressed?.call(); + }, + child: Container( + width: width, + height: height, + child: CustomPaint( + painter: + _ButtonPainer(_pressed ? widget.pressedSprite : widget.sprite), + child: Center( + child: Container( + padding: _pressed ? const EdgeInsets.only(top: 5) : null, + child: widget.label, ), + ), ), + ), ); } }