Skip to content

Commit 81ecb88

Browse files
Ilya Yanokcopybara-github
authored andcommitted
Fix one README example that were broken by 1dcd822
Also sync the executable version of it with the README. Fixes #744 PiperOrigin-RevId: 623800048
1 parent 3ef744f commit 81ecb88

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,17 @@ In most cases, both plain arguments and argument matchers can be passed into
170170
mock methods:
171171

172172
```dart
173-
// You can use plain arguments themselves
173+
// You can use `any`
174+
when(cat.eatFood(any)).thenReturn(false);
175+
176+
// ... or plain arguments themselves
174177
when(cat.eatFood("fish")).thenReturn(true);
175178
176179
// ... including collections
177180
when(cat.walk(["roof","tree"])).thenReturn(2);
178181
179182
// ... or matchers
180183
when(cat.eatFood(argThat(startsWith("dry")))).thenReturn(false);
181-
when(cat.eatFood(any)).thenReturn(false);
182184
183185
// ... or mix arguments with matchers
184186
when(cat.eatFood(argThat(startsWith("dry")), hungry: true)).thenReturn(true);

example/example.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ void main() {
8888
});
8989

9090
test('Argument matchers', () {
91-
// You can use plain arguments themselves
92-
when(cat.eatFood('fish')).thenReturn(true);
91+
// You can use `any`
92+
when(cat.eatFood(any)).thenReturn(false);
93+
94+
// ... or plain arguments themselves
95+
when(cat.eatFood("fish")).thenReturn(true);
9396

9497
// ... including collections
9598
when(cat.walk(['roof', 'tree'])).thenReturn(2);

0 commit comments

Comments
 (0)