Skip to content

Commit 3e82629

Browse files
authored
[go_router] fix(docs): typo in example extra_codec.dart (flutter#5570)
Replace ``` throw FormatException('Unable tp parse input: $input'); ``` by ``` throw FormatException('Unable to parse input: $input'); ```
1 parent d30bdd9 commit 3e82629

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/go_router/example/lib/extra_codec.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class _MyExtraDecoder extends Converter<Object?, Object?> {
116116
if (inputAsList[0] == 'ComplexData2') {
117117
return ComplexData2(inputAsList[1]! as String);
118118
}
119-
throw FormatException('Unable tp parse input: $input');
119+
throw FormatException('Unable to parse input: $input');
120120
}
121121
}
122122

packages/go_router/example/test/extra_codec_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,20 @@ void main() {
2020
expect(find.text('The extra for this page is: ComplexData2(data: data)'),
2121
findsOneWidget);
2222
});
23+
24+
test('invalid extra throws', () {
25+
const example.MyExtraCodec extraCodec = example.MyExtraCodec();
26+
const List<Object?> invalidValue = <Object?>['invalid'];
27+
28+
expect(
29+
() => extraCodec.decode(invalidValue),
30+
throwsA(
31+
predicate(
32+
(Object? exception) =>
33+
exception is FormatException &&
34+
exception.message == 'Unable to parse input: $invalidValue',
35+
),
36+
),
37+
);
38+
});
2339
}

0 commit comments

Comments
 (0)