-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Closed
Labels
found in release: 3.5Found to occur in 3.5Found to occur in 3.5frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Please see linked PR for reproduction
copied here:
In short, the SnapshotWidget is rendered differently when enabled vs disabled.
Reproduction:
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
final binding = TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('SnapshotWidget should have same result when enabled', (tester) async {
binding.window
..physicalSizeTestValue = const Size(10, 10)
..devicePixelRatioTestValue = 1;
addTearDown(() => binding.window
..clearPhysicalSizeTestValue()
..clearDevicePixelRatioTestValue());
final controller = SnapshotController(allowSnapshotting: false);
await tester.pumpWidget(MaterialApp(
debugShowCheckedModeBanner: false,
home: Container(
color: Colors.black,
padding: const EdgeInsets.only(right: 0.6, bottom: 0.6),
child: SnapshotWidget(
controller: controller,
child: Container(
margin: const EdgeInsets.only(right: 0.4, bottom: 0.4),
color: Colors.blue,
),
),
),
));
final imageWhenDisabled = await _captureImage(tester.element(find.byType(MaterialApp)));
controller.allowSnapshotting = true;
await tester.pump();
final imageWhenEnabled = await _captureImage(tester.element(find.byType(MaterialApp)));
await expectLater(imageWhenEnabled, matchesReferenceImage(imageWhenDisabled));
});
}
Future<ui.Image> _captureImage(Element element) {
assert(element.renderObject != null);
RenderObject renderObject = element.renderObject!;
while (!renderObject.isRepaintBoundary) {
renderObject = renderObject.parent! as RenderObject;
}
assert(!renderObject.debugNeedsPaint);
final OffsetLayer layer = renderObject.debugLayer! as OffsetLayer;
return layer.toImage(renderObject.paintBounds);
}
If you dump the images, will see:
Metadata
Metadata
Assignees
Labels
found in release: 3.5Found to occur in 3.5Found to occur in 3.5frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version