https://dart.dev/guides/language/effective-dart/style#prefer-using-_-__-etc-for-unused-callback-parameters

 

Effective Dart: Style

Formatting and naming rules for consistent, readable code.

dart.dev

PREFER using _, __, etc. for unused callback parameters.

Sometimes the type signature of a callback function requires a parameter, but the callback implementation doesn’t use the parameter. In this case, it’s idiomatic to name the unused parameter _. If the function has multiple unused parameters, use additional underscores to avoid name collisions: __, ___, etc.

(구글번역)

사용 하지 않는 콜백 매개변수 _에는 __, 등을 사용하는 것이 좋습니다.

때때로 콜백 함수의 유형 서명에는 매개변수가 필요하지만 콜백 구현에서는 매개변수를 사용 하지 않습니다 . 이 경우에는  사용하지 않는 매개변수의 이름을 '_'로 지정하는 것이 자연스럽다 . 함수에 사용하지 않는 매개변수가 여러 개 있는 경우 이름 충돌을 방지하기 위해 추가 밑줄을 사용하십시오 __( ___, 등).

futureOfVoid.then((_) {
  print('Operation complete.');
});

This guideline is only for functions that are both anonymous and local. These functions are usually used immediately in a context where it’s clear what the unused parameter represents. In contrast, top-level functions and method declarations don’t have that context, so their parameters must be named so that it’s clear what each parameter is for, even if it isn’t used.

(구글번역)

이 지침은 익명 및 로컬 기능에 대한 것입니다 . 이러한 함수는 일반적으로 사용되지 않는 매개변수가 나타내는 것이 명확한 컨텍스트에서 즉시 사용됩니다. 대조적으로, 최상위 함수 및 메서드 선언에는 해당 컨텍스트가 없으므로 매개변수의 이름이 지정되어야 사용되지 않더라도 각 매개변수의 용도가 명확해집니다.

+ Recent posts