avoid-public-notifier-properties
- Group
- Style
- Path
lint/style/avoid-public-notifier-properties- Default
- Off, opt in
- Origin
- Falcon
- Domain
- riverpod
- Rule
- 116 of 512
riverpod
Keeps notifier state behind Riverpod's observable state property.
Invalid
example.dartdart
import 'package:riverpod/riverpod.dart';
abstract class Counter extends Notifier<int> {
int count = 0;
final int initial = 0;
int get current => count;
set current(int value) { count = value; }
}
abstract class AsyncCounter extends AsyncNotifier<int> {
int cached = 0;
}
abstract class Derived extends Counter {
int extra = 0;
}Expose notifier data through state rather than a public property.
2
abstract class Counter extends Notifier<int> {3
int count = 0;Expose notifier data through state rather than a public property.
3
int count = 0;4
final int initial = 0;Expose notifier data through state rather than a public property.
4
final int initial = 0;5
int get current => count;Expose notifier data through state rather than a public property.
5
int get current => count;6
set current(int value) { count = value; }Expose notifier data through state rather than a public property.
8
abstract class AsyncCounter extends AsyncNotifier<int> {9
int cached = 0;Expose notifier data through state rather than a public property.
11
abstract class Derived extends Counter {12
int extra = 0;Valid
example.dartdart
import 'package:riverpod/riverpod.dart' as rp;
abstract class Good extends rp.Notifier<int> {
int _count = 0;
int get _current => _count;
set _current(int value) { _count = value; }
static int cache = 0;
int build() => _count;
void increment() { state = state + 1; }
}
class Notifier<T> {}
class Unrelated extends Notifier<int> { int publicValue = 0; }
class Plain { int value = 0; int get other => value; }Configure avoid-public-notifier-properties
Set its severity in falcon.json. See the configuration guide.
falcon.jsonjson
{
"linter": {
"rules": {
"style": {
"avoid-public-notifier-properties": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
example.dartdart
// falcon-ignore lint/style/avoid-public-notifier-properties: <reason>More style rules
- 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.
- avoid-single-cascade-in-expression-statements
avoid_single_cascade_in_expression_statementsrecommendedFlags an expression statement that is a cascade with a single section.