avoid-passing-bloc-to-bloc
- Group
- Suspicious
- Path
lint/suspicious/avoid-passing-bloc-to-bloc- Default
- Off, opt in
- Origin
- Falcon
- Domain
- bloc
- Rule
- 109 of 512
Rejects direct Bloc and Cubit arguments to other blocs.
Invalid
import 'support.dart';
import 'package:bloc/bloc.dart' as b;
typedef ConsumerAlias = Consumer;
class ConsumerCubit extends b.Cubit<int> {
ConsumerCubit(Object dependency) : super(0);
}
void dependencies(Counter counter, Consumer consumer, b.Cubit<int> cubit) {
Consumer(counter);
new Consumer(counter);
Consumer.named(dependency: cubit);
ChildConsumer(counter);
ConsumerAlias(counter);
consumer.accept(counter);
Consumer(Counter());
ConsumerCubit(counter);
consumer..accept(counter);
}
class ImplicitConsumer extends b.Cubit<int> {
ImplicitConsumer() : super(0);
void accept(Object dependency) {}
void dependencies(Counter counter) {
accept(counter);
this.accept(counter);
}
}
class InheritedConsumer extends ImplicitConsumer {
void inherited(Counter counter) {
accept(counter);
}
}void dependencies(Counter counter, Consumer consumer, b.Cubit<int> cubit) { Consumer(counter); Consumer(counter); new Consumer(counter); new Consumer(counter); Consumer.named(dependency: cubit); Consumer.named(dependency: cubit); ChildConsumer(counter); ChildConsumer(counter); ConsumerAlias(counter); ConsumerAlias(counter); consumer.accept(counter); consumer.accept(counter); Consumer(Counter()); Consumer(Counter()); ConsumerCubit(counter); ConsumerCubit(counter); consumer..accept(counter); void dependencies(Counter counter) { accept(counter); accept(counter); this.accept(counter); void inherited(Counter counter) { accept(counter);Valid
import 'support.dart' as real;
class Bloc<E, S> {}
class Cubit<S> {}
class LocalBloc extends Bloc<Object, int> {
LocalBloc(Object dependency);
}
class LookupConsumer extends real.Consumer {
LookupConsumer() : super(0);
static LookupConsumer of(real.Counter counter) => LookupConsumer();
}
void boundaries(real.Counter counter, real.Consumer consumer, dynamic unknown) {
real.Consumer(real.Repository(0));
real.Repository(counter);
real.View(counter);
real.Consumer(Cubit<int>());
real.Consumer(Bloc<Object, int>());
real.Consumer(unknown);
LocalBloc(counter);
consumer.accept(1);
consumer..accept(1);
LookupConsumer.of(counter);
final Consumer = (Object dependency) => real.Repository(dependency);
Consumer(counter);
}
void accept(Object value) {}
class ShadowedConsumer extends real.Consumer {
ShadowedConsumer() : super(0);
void localVariable(real.Counter counter) {
final accept = (Object value) {};
accept(counter);
}
void localFunction(real.Counter counter) {
void accept(Object value) {}
accept(counter);
}
void parameter(real.Counter counter, void Function(Object) accept) {
accept(counter);
}
void libraryFunction(real.Counter counter) {
accept(counter);
}
static void helper(Object value) {}
void staticFunction(real.Counter counter) {
helper(counter);
}
}Configure avoid-passing-bloc-to-bloc
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"suspicious": {
"avoid-passing-bloc-to-bloc": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/suspicious/avoid-passing-bloc-to-bloc: <reason>More suspicious rules
- avoid-passing-bloc-to-widgetbloc
Rejects direct Bloc and Cubit arguments to Flutter widget constructors.
- avoid-passing-build-context-to-blocsbloc
Keeps Flutter
BuildContextarguments outside Bloc and Cubit APIs. - avoid-print
avoid_printrecommendedflutterFlags calls and callback arguments resolving to
dart:core'sprint. - avoid-referencing-subclasses
Keeps base classes independent from their transitive subclasses.
- avoid-returning-null-for-void
avoid_returning_null_for_voidrecommendedFlags
return null;(and=> nullbodies) in synchronousvoidfunctions and asynchronousFuture<void>functions. - avoid-shadowed-extension-methods
Flags extension instance methods and accessors hidden by their target's members.
- avoid-shadowing
Flags local bindings and parameters that hide an enclosing type's member.
- avoid-shadowing-type-parameters
avoid_shadowing_type_parametersrecommendedFlags a type parameter that shadows a type parameter of an enclosing declaration.