diff --git a/packages/go_router/example/lib/extra_codec.dart b/packages/go_router/example/lib/extra_codec.dart index 497312cb530..f7ae2a4f576 100644 --- a/packages/go_router/example/lib/extra_codec.dart +++ b/packages/go_router/example/lib/extra_codec.dart @@ -116,7 +116,7 @@ class _MyExtraDecoder extends Converter { if (inputAsList[0] == 'ComplexData2') { return ComplexData2(inputAsList[1]! as String); } - throw FormatException('Unable tp parse input: $input'); + throw FormatException('Unable to parse input: $input'); } } diff --git a/packages/go_router/example/test/extra_codec_test.dart b/packages/go_router/example/test/extra_codec_test.dart index 7358cfc614e..e42b19ddb3b 100644 --- a/packages/go_router/example/test/extra_codec_test.dart +++ b/packages/go_router/example/test/extra_codec_test.dart @@ -20,4 +20,20 @@ void main() { expect(find.text('The extra for this page is: ComplexData2(data: data)'), findsOneWidget); }); + + test('invalid extra throws', () { + const example.MyExtraCodec extraCodec = example.MyExtraCodec(); + const List invalidValue = ['invalid']; + + expect( + () => extraCodec.decode(invalidValue), + throwsA( + predicate( + (Object? exception) => + exception is FormatException && + exception.message == 'Unable to parse input: $invalidValue', + ), + ), + ); + }); }