The fixture resolves with no pub get and no network, which is why .dart_tool/package_config.json is committed by hand. Adding a package: import would silently break every rule test that depends on it, so the constraint is now stated where someone would violate it.
54 lines
1.9 KiB
Dart
54 lines
1.9 KiB
Dart
// UI-side fixture. Every declaration here is a hand-written stand-in (see
|
|
// bloc.dart, notifier.dart, provider_setup.dart) because this fixture is
|
|
// deliberately DEPENDENCY-FREE: it must resolve with no `pub get` and no
|
|
// network, which is why .dart_tool/package_config.json is committed by hand.
|
|
// Do not add a `package:` import to any file in this fixture - it would break
|
|
// that property, and the rule tests that depend on it.
|
|
|
|
import 'bloc.dart';
|
|
import 'gaps.dart';
|
|
import 'notifier_gaps.dart';
|
|
|
|
/// A widget-like consumer. It declares no Bloc/Cubit, so type tests in this
|
|
/// file count as UI-facing.
|
|
class GapView {
|
|
const GapView();
|
|
|
|
Object build() => BlocBuilder<GapBloc, GapState>(
|
|
builder: (context, state) {
|
|
// BAD: branches on GapGhost, which GapBloc never emits (dead UI), and
|
|
// never renders GapIdle, which it does emit.
|
|
if (state is GapGhost) return 'ghost';
|
|
return 'ok';
|
|
},
|
|
);
|
|
}
|
|
|
|
/// Renders AlphaState's DuplicatedName but never BetaState's, even though the
|
|
/// two variants share a simple name.
|
|
class AlphaView {
|
|
const AlphaView();
|
|
|
|
Object build() => BlocBuilder<AlphaBloc, AlphaState>(
|
|
builder: (context, state) => switch (state) {
|
|
DuplicatedName value => value,
|
|
},
|
|
);
|
|
}
|
|
|
|
/// Renders every variant PatternBloc can emit, so PatternState is the negative
|
|
/// control for `rendered-not-emitted`: a union WITH render sites whose rendered
|
|
/// variants are all actually emitted. Without a case like this, asserting
|
|
/// "PatternState is not reported" proves nothing, because a union with no render
|
|
/// sites could never be reported either.
|
|
class PatternView {
|
|
const PatternView();
|
|
|
|
Object build() => BlocBuilder<PatternBloc, PatternState>(
|
|
builder: (context, state) => switch (state) {
|
|
PatternA value => value,
|
|
PatternB value => value,
|
|
_ => 'none',
|
|
},
|
|
);
|
|
}
|