Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/core/motion/querya_cross_fade_stack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class QueryaCrossFadeStack extends StatelessWidget {
opacity: index == i ? 1 : 0,
duration: duration,
curve: curve,
child: children[i],
child: TickerMode(
enabled: index == i,
child: RepaintBoundary(child: children[i]),
),
),
),
),
Expand Down
7 changes: 6 additions & 1 deletion lib/core/motion/querya_switching_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ class _SwitchingLayer extends StatelessWidget {
@override
Widget build(BuildContext context) {
final curve = active ? inCurve : outCurve;
// Isolate paint; pause child tickers when inactive (opacity anim still runs).
final content = TickerMode(
enabled: active,
child: RepaintBoundary(child: child),
);
Widget layer = AnimatedOpacity(
opacity: active ? 1 : 0,
duration: duration,
curve: curve,
child: child,
child: content,
);

if (slide != Offset.zero) {
Expand Down
35 changes: 35 additions & 0 deletions test/core/motion/querya_switching_body_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,41 @@ void main() {
);
});

testWidgets('inactive layer disables TickerMode and uses RepaintBoundary',
(tester) async {
await tester.pumpWidget(
wrap(
const QueryaSwitchingBody(
index: 0,
children: [
Text('active'),
Text('inactive'),
],
),
),
);

final tickers = tester
.widgetList<TickerMode>(
find.descendant(
of: find.byType(QueryaSwitchingBody),
matching: find.byType(TickerMode),
),
)
.toList();
expect(tickers.length, 2);
expect(tickers.first.enabled, isTrue);
expect(tickers.last.enabled, isFalse);

expect(
find.descendant(
of: find.byType(QueryaSwitchingBody),
matching: find.byType(RepaintBoundary),
),
findsNWidgets(2),
);
});

testWidgets('ExcludeSemantics excludes inactive child', (tester) async {
await tester.pumpWidget(
wrap(
Expand Down
Loading