mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
👌 Throw exception from parseAnchor in examples/widgets instead of returning null (#632)
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
## [next]
|
## [next]
|
||||||
|
- Changed `parseAnchor` in `examples/widgets` to throw an exception instead of returning null when it cannot parse an anchor name
|
||||||
- Code improvements and preparing APIs to null-safety
|
- Code improvements and preparing APIs to null-safety
|
||||||
- BaseComponent removes children marked as shouldRemove during update
|
- BaseComponent removes children marked as shouldRemove during update
|
||||||
- Use `find` instead of `globstar` pattern in `scripts/lint.sh` as the later isn't enabled by default in bash
|
- Use `find` instead of `globstar` pattern in `scripts/lint.sh` as the later isn't enabled by default in bash
|
||||||
|
|||||||
@ -33,7 +33,7 @@ Anchor parseAnchor(String name) {
|
|||||||
return Anchor.bottomRight;
|
return Anchor.bottomRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw Exception("Cannot parse anchor name `$name`");
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
@ -108,9 +108,8 @@ void main() async {
|
|||||||
child: SpriteWidget(
|
child: SpriteWidget(
|
||||||
sprite: shieldSprite,
|
sprite: shieldSprite,
|
||||||
anchor: parseAnchor(
|
anchor: parseAnchor(
|
||||||
ctx.listProperty('anchor', 'Anchor.center', anchorOptions),
|
ctx.listProperty('anchor', 'Anchor.center', anchorOptions),
|
||||||
) ??
|
),
|
||||||
Anchor.topLeft,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -135,9 +134,8 @@ void main() async {
|
|||||||
animation: _animation,
|
animation: _animation,
|
||||||
playing: ctx.boolProperty('playing', true),
|
playing: ctx.boolProperty('playing', true),
|
||||||
anchor: parseAnchor(
|
anchor: parseAnchor(
|
||||||
ctx.listProperty('anchor', 'Anchor.center', anchorOptions),
|
ctx.listProperty('anchor', 'Anchor.center', anchorOptions),
|
||||||
) ??
|
),
|
||||||
Anchor.topLeft,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user