Fixing center repaint

This commit is contained in:
Erick Zanardo
2020-05-25 11:46:46 -03:00
parent 96a6ce31c2
commit a8e0bbd5a1
3 changed files with 4 additions and 3 deletions

View File

@ -67,11 +67,12 @@ void main() async {
dashbook.storiesOf('FlameSpriteWidget').decorator(CenterDecorator()).add( dashbook.storiesOf('FlameSpriteWidget').decorator(CenterDecorator()).add(
'default', 'default',
(ctx) => Container( (ctx) => Container(
width: ctx.numberProperty('container width', 200), width: ctx.numberProperty('container width', 400),
height: ctx.numberProperty('container height', 200), height: ctx.numberProperty('container height', 200),
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
child: FlameSpriteWidget( child: FlameSpriteWidget(
sprite: shieldSprite, sprite: shieldSprite,
center: ctx.boolProperty('center', true),
), ),
), ),
); );

View File

@ -11,7 +11,7 @@ dependencies:
sdk: flutter sdk: flutter
flame: flame:
path: ../../../ path: ../../../
dashbook: ^0.0.4 dashbook: ^0.0.5
cupertino_icons: ^0.1.2 cupertino_icons: ^0.1.2
flutter: flutter:

View File

@ -28,7 +28,7 @@ class _FlameSpritePainer extends CustomPainter {
_FlameSpritePainer(this._sprite, this._center); _FlameSpritePainer(this._sprite, this._center);
@override @override
bool shouldRepaint(_FlameSpritePainer old) => old._sprite != _sprite; bool shouldRepaint(_FlameSpritePainer old) => old._sprite != _sprite || old._center != _center;
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {