From 11d93c23b2cc4fa03bcef79e4aece94dc6b1a94c Mon Sep 17 00:00:00 2001 From: Serge Matveenko Date: Sun, 17 Jan 2021 17:10:03 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Throw=20exception=20from=20`pars?= =?UTF-8?q?eAnchor`=20in=20`examples/widgets`=20instead=20of=20returning?= =?UTF-8?q?=20null=20(#632)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + doc/examples/widgets/lib/main.dart | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f97a25f4f..e52c7c3a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/doc/examples/widgets/lib/main.dart b/doc/examples/widgets/lib/main.dart index 0b14a5f32..e0fa3a1ff 100644 --- a/doc/examples/widgets/lib/main.dart +++ b/doc/examples/widgets/lib/main.dart @@ -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), + ), ), ), );