avoid-private-typedef-functions
Same as avoid_private_typedef_functions in Dart lints
- Group
- Style
- Path
lint/style/avoid-private-typedef-functions- Default
- Off, opt in
- Origin
- Dart lints
- Rule
- 115 of 512
Flags a private function typedef that is used at most once.
A private typedef for a function type only saves typing when it is reused.
Used once (or never), an inline Function(...) type is clearer:
typedef _Callback = void Function(int); // flagged: used once
void register(_Callback cb) {}
typedef void _Legacy(int x); // flagged: never used
Generic typedef _F<T> = ... aliases and aliases of non-function types are
not reported; legacy typedef void _F(...) forms always are. Uses are
counted as type annotations across every file of the library. When the
library has part files that falcon cannot see, the rule stays silent.
Invalid
typedef _Unused = void Function(int);
typedef _UsedOnce = int Function(String);
typedef void _Legacy(int x);
typedef _LegacyGeneric<T> = void Function(T); // generic: not reported
typedef T _LegacyWithTypeParams<T>(T value);
typedef _Nullable = bool Function()?;
void register(_UsedOnce callback) {}
_Nullable? holder;typedef _Unused = void Function(int); typedef _UsedOnce = int Function(String); typedef void _Legacy(int x); typedef T _LegacyWithTypeParams<T>(T value); typedef _Nullable = bool Function()?;Valid
// Public typedefs are not checked.
typedef Callback = void Function(int);
// Used more than once.
typedef _Handler = void Function(String);
void on(_Handler handler) {}
void off(_Handler handler) {}
// Generic aliases are not reported.
typedef _Mapper<T> = T Function(T);
// Aliases of non-function types are not reported.
typedef _Ints = List<int>;
typedef _Pair = (int, int);
// Legacy typedef used twice.
typedef void _Listener(int event);
final List<_Listener> listeners = <_Listener>[];
void main() {
_Mapper<int>? mapper;
_Ints? ints;
_Pair? pair;
print('$mapper $ints $pair');
}Configure avoid-private-typedef-functions
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"avoid-private-typedef-functions": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/avoid-private-typedef-functions: <reason>More style rules
- avoid-public-notifier-propertiesriverpod
Keeps notifier state behind Riverpod's observable state property.
- avoid-redundant-argument-values
avoid_redundant_argument_valuesFlags arguments that pass exactly the parameter's default value.
- avoid-redundant-else
Flags else branches after an if body that unconditionally returns or throws.
- avoid-redundant-pattern-field-names
avoid_redundant_pattern_field_namesrecommendedFlags redundant field names in object and record patterns.
- avoid-renaming-method-parameters
avoid_renaming_method_parametersRequires overriding methods to keep the positional parameter names of the member they inherit.
- avoid-return-types-on-setters
avoid_return_types_on_settersrecommendedFlags setters declared with an explicit return type.
- avoid-returning-this
avoid_returning_thisFlags methods that return
thisonly to enable a fluent interface. - avoid-setters-without-getters
avoid_setters_without_gettersFlags a setter that has no corresponding getter.