vendredi 4 octobre 2019

What is the purpose of underline sign using (_) { } in Flutter?

I'm learing to Mock dependencies using Mockito in Flutter from https://flutter.dev/docs/cookbook/testing/unit/mocking guide.

I don't understand a following line:

when(client.get('https://jsonplaceholder.typicode.com/posts/1'))
          .thenAnswer((_) async => http.Response('{"title": "Test"}', 200));

What underline sign does in (_) {} exactly? From what I've learned () is used to pass arguments that need to be used inside {} body. What are we axactly passing to function when writing _?

Aucun commentaire:

Enregistrer un commentaire