{
  "id": "flutter/golden-test-image-size-mismatch",
  "signature": "TestFailure: Golden image dimensions do not match: expected 1080x1920, actual 720x1280",
  "signature_zh": "TestFailure: Golden 图像尺寸不匹配：期望 1080x1920，实际 720x1280",
  "regex": "TestFailure: Golden image dimensions do not match: expected \\d+x\\d+, actual \\d+x\\d+",
  "domain": "flutter",
  "category": "test_error",
  "subcategory": null,
  "root_cause": "The golden file used for image comparison has different dimensions than the rendered widget, often due to a change in screen size, widget layout, or test device configuration.",
  "root_cause_type": "generic",
  "root_cause_zh": "用于图像比较的 golden 文件与渲染的小部件尺寸不同，通常是由于屏幕尺寸、小部件布局或测试设备配置发生变化。",
  "versions": [
    {
      "version": "Flutter 3.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Flutter 3.19.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Dart 3.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Update the golden file manually by copying the actual output to the golden directory",
      "why_fails": "If the layout change is unintended, copying the output introduces a false positive; the test passes but the UI is broken.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Set a fixed screen size in the test using TestWidgetsFlutterBinding",
      "why_fails": "Fixing the screen size may not match the golden's expected dimensions; the dimensions must align exactly.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use 'matchGoldenFile' with a tolerance parameter to ignore size differences",
      "why_fails": "The 'matchGoldenFile' method does not have a tolerance parameter for dimensions; it only compares pixel data after resizing, which can cause blurry comparisons.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Regenerate the golden file by running the test with the '--update-goldens' flag. Example:\n  flutter test --update-goldens test/widget_test.dart\nThis overwrites the golden file with the current rendered output.",
      "success_rate": 0.9,
      "how": "Regenerate the golden file by running the test with the '--update-goldens' flag. Example:\n  flutter test --update-goldens test/widget_test.dart\nThis overwrites the golden file with the current rendered output.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure the test widget is rendered at the same size as the golden. In the test, set a fixed surface size using:\n  testWidgets('golden test', (tester) async {\n    await tester.binding.setSurfaceSize(Size(1080, 1920));\n    await tester.pumpWidget(MyWidget());\n    await expectLater(find.byType(MyWidget), matchesGoldenFile('golden.png'));\n  });",
      "success_rate": 0.85,
      "how": "Ensure the test widget is rendered at the same size as the golden. In the test, set a fixed surface size using:\n  testWidgets('golden test', (tester) async {\n    await tester.binding.setSurfaceSize(Size(1080, 1920));\n    await tester.pumpWidget(MyWidget());\n    await expectLater(find.byType(MyWidget), matchesGoldenFile('golden.png'));\n  });",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check for responsive layout changes that alter widget dimensions; wrap the widget in a SizedBox with fixed size in the test to match the golden.",
      "success_rate": 0.8,
      "how": "Check for responsive layout changes that alter widget dimensions; wrap the widget in a SizedBox with fixed size in the test to match the golden.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "通过使用 '--update-goldens' 标志运行测试来重新生成 golden 文件。示例：\n  flutter test --update-goldens test/widget_test.dart\n这将用当前渲染输出覆盖 golden 文件。",
    "确保测试小部件以与 golden 相同的尺寸渲染。在测试中，使用以下方法设置固定表面尺寸：\n  testWidgets('golden test', (tester) async {\n    await tester.binding.setSurfaceSize(Size(1080, 1920));\n    await tester.pumpWidget(MyWidget());\n    await expectLater(find.byType(MyWidget), matchesGoldenFile('golden.png'));\n  });",
    "检查可能改变小部件尺寸的响应式布局更改；在测试中使用固定大小的 SizedBox 包装小部件以匹配 golden。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.flutter.dev/testing/golden-testing",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-07-12",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}