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

2,128

Its a variable name and I am using _ when i dont wanna use parameter. Normally _ used for private, but in this case its not about private.

Share:
2,128
Stahp
Author by

Stahp

I seem to be wounded...but I can keep going.

Updated on December 14, 2022

Comments

  • Stahp
    Stahp over 1 year

    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 _?