👌 Throw exception from parseAnchor in examples/widgets instead of returning null (#632)

This commit is contained in:
Serge Matveenko
2021-01-17 17:10:03 +03:00
committed by GitHub
parent 2d68ba0feb
commit 11d93c23b2
2 changed files with 6 additions and 7 deletions

View File

@ -1,6 +1,7 @@
# CHANGELOG
## [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
- 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

View File

@ -33,7 +33,7 @@ Anchor parseAnchor(String name) {
return Anchor.bottomRight;
}
return null;
throw Exception("Cannot parse anchor name `$name`");
}
void main() async {
@ -108,9 +108,8 @@ void main() async {
child: SpriteWidget(
sprite: shieldSprite,
anchor: parseAnchor(
ctx.listProperty('anchor', 'Anchor.center', anchorOptions),
) ??
Anchor.topLeft,
ctx.listProperty('anchor', 'Anchor.center', anchorOptions),
),
),
),
);
@ -135,9 +134,8 @@ void main() async {
animation: _animation,
playing: ctx.boolProperty('playing', true),
anchor: parseAnchor(
ctx.listProperty('anchor', 'Anchor.center', anchorOptions),
) ??
Anchor.topLeft,
ctx.listProperty('anchor', 'Anchor.center', anchorOptions),
),
),
),
);