Repository: flutter
Issue: Long text in FittedBox shrinks InkWell below accessibility tap target size
Labels: a: tests,framework,a: accessibility,has reproducible steps,P2,found in release: 3.24,team-accessibility,triaged-accessibility,found in release: 3.26

### Steps to reproduce

1. Create a flutter application
2. In test, create a test file
3. Copy and paste Code section in
4. Run tests

### Expected results

Both tests passed.

### Actual results

Having larger text seems to shrink the button for `meetsGuideline(androidTapTargetGuideline)`

```bash
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: Tappable objects should be at least Size(48.0, 48.0)
  Actual: <Instance of 'WidgetTester'>
   Which: SemanticsNode#7(Rect.fromLTRB(0.0, 0.0, 382.0, 47.9), tags: [RenderViewport.twoPane],
actions: [focus, tap], flags: [isFocusable], label: "ABCDEFGHIJKLMNOPQRS", textDirection: ltr,
indexInParent: 0): expected tap target size of at least Size(48.0, 48.0), but found Size(382.0,
47.9)
          See also: https://support.google.com/accessibility/android/answer/7101858?hl=en

When the exception was thrown, this was the stack:
#0      fail (package:matcher/src/expect/expect.dart:149:31)
#1      _expect.<anonymous closure> (package:matcher/src/expect/expect.dart:125:9)
<asynchronous suspension>
<asynchronous suspension>
#8      expectLater.<anonymous closure> (package:flutter_test/src/widget_tester.dart:518:24)
<asynchronous suspension>
#9      _testAccessibility (file:///Users/lucassaudon/work/my_trash_app/test/widget_test.dart:71:3)
<asynchronous suspension>
#10     main.<anonymous closure> (file:///Users/lucassaudon/work/my_trash_app/test/widget_test.dart:9:5)
<asynchronous suspension>
#11     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:189:15)
<asynchronous suspension>
#12     TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1032:5)
<asynchronous suspension>
<asynchronous suspension>
(elided 7 frames from dart:async and package:stack_trace)

The test description was:
  Given a long string, when rendered, then it meets accessibility guidelines
════════════════════════════════════════════════════════════════════════════════════════════════════
```

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets(
      'Given a long string, when rendered, then it meets accessibility guidelines',
      (WidgetTester tester) async {
    const data = 'ABCDEFGHIJKLMNOPQRS';
    await _testAccessibility(tester, data);
  });

  testWidgets(
      'Given a slightly shorter string, when rendered, then it meets accessibility guidelines',
      (WidgetTester tester) async {
    const data = 'ABCDEFGHIJKLMNOPQR';
    await _testAccessibility(tester, data);
  });
}

Future<void> _testAccessibility(WidgetTester tester, String data) async {
  tester.view
    ..devicePixelRatio = 2
    ..physicalSize = Size(2 * 414, 2 * 896);
  addTearDown(tester.view.resetDevicePixelRatio);
  addTearDown(tester.view.resetPhysicalSize);
  final handle = tester.ensureSemantics();
  await tester.pumpWidget(
    MaterialApp(
      home: Scaffold(
        body: ListView(
          padding: const EdgeInsets.symmetric(vertical: 24),
          children: [
            Padding(
              padding: const EdgeInsets.symmetric(horizontal: 16),
              child: ListView(
                physics: const NeverScrollableScrollPhysics(),
                shrinkWrap: true,
                children: [
                  Align(
                    alignment: Alignment.centerLeft,
                    child: FittedBox(
                      child: InkWell(
                        onTap: () {},
                        child: ConstrainedBox(
                          constraints: const BoxConstraints(minHeight: 48),
                          child: Padding(
                            padding: const EdgeInsets.symmetric(
                              vertical: 10,
                              horizontal: 18,
                            ),
                            child: Text(
                              data,
                              style: const TextStyle(
                                fontSize: 18,
                              ),
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    ),
  );

  await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
  handle.dispose();
}
```

</details>

### Logs

<details open><summary>Logs</summary>

```console
[   +2 ms] executing: sw_vers -productName
[  +12 ms] Exit code 0 from: sw_vers -productName
[        ] macOS
[        ] executing: sw_vers -productVersion
[   +6 ms] Exit code 0 from: sw_vers -productVersion
[        ] 15.0.1
[        ] executing: sw_vers -buildVersion
[   +6 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 24A348
[        ] executing: uname -m
[   +2 ms] Exit code 0 from: uname -m
[        ] arm64
[   +3 ms] executing: sysctl hw.optional.arm64
[   +2 ms] Exit code 0 from: sysctl hw.optional.arm64
[        ] hw.optional.arm64: 1
[  +23 ms] Found 1 files which will be executed as Widget Tests.
[   +2 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +13 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[  +24 ms] Skipping pub get: version match.
[  +63 ms] Generating /Users/lucassaudon/work/my_trash_app/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[  +10 ms] executing: sysctl hw.optional.arm64
[   +2 ms] Exit code 0 from: sysctl hw.optional.arm64
[        ] hw.optional.arm64: 1
[        ] executing: /usr/bin/arch -arm64e xcrun xcodebuild -version
[  +37 ms] Exit code 0 from: /usr/bin/arch -arm64e xcrun xcodebuild -version
[        ] Xcode 16.0
           Build version 16A242d
[  +70 ms] running test package with arguments: [--no-color, --chain-stack-traces, --, file:///Users/lucassaudon/work/my_trash_app/test/widget_test.dart]

00:00 +0: loading /Users/lucassaudon/work/my_trash_app/test/widget_test.dart                                                                                                                           [  +76 ms] test 0: starting test /Users/lucassaudon/work/my_trash_app/test/widget_test.dart
[   +2 ms] Stopping scan for flutter_test_config.dart; found project root at /Users/lucassaudon/work/my_trash_app
[        ] Compiler will use the following file as its incremental dill file: /var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_compiler.6WuDJf/output.dill
[        ] Listening to compiler controller...
[   +3 ms] Compiling file:///var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_listener.dt6gWC/listener.dart
[  +23 ms] No packages with native assets. Skipping native assets compilation.
[        ] Writing native_assets.yaml.
[   +4 ms] Writing /Users/lucassaudon/work/my_trash_app/build/native_assets/macos/native_assets.yaml done.
[   +1 ms] /Users/lucassaudon/development/flutter/bin/cache/dart-sdk/bin/dartaotruntime --disable-dart-dev /Users/lucassaudon/development/flutter/bin/cache/dart-sdk/bin/snapshots/frontend_server_aot.dart.snapshot --sdk-root /Users/lucassaudon/development/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --no-print-incremental-dependencies --target=flutter --experimental-emit-debug-metadata --output-dill /var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_compiler.6WuDJf/output.dill --packages /Users/lucassaudon/work/my_trash_app/.dart_tool/package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --initialize-from-dill /Users/lucassaudon/work/my_trash_app/build/test_cache/build/cache.dill.track.dill --native-assets file:///Users/lucassaudon/work/my_trash_app/build/native_assets/macos/native_assets.yaml --verbosity=error
[   +6 ms] <- native-assets file:///Users/lucassaudon/work/my_trash_app/build/native_assets/macos/native_assets.yaml
[        ] <- compile file:///var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_listener.dt6gWC/listener.dart
[ +426 ms] <- accept
[        ] <- reset
[        ] Compiling file:///var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_listener.dt6gWC/listener.dart took 462ms
[        ] test 0: starting test device
[   +1 ms] test 0: awaiting connection to test device
[        ] test 0: VM Service uri is not available
[   +1 ms] test 0: test harness socket server is running at port:60387
[        ] Using this directory for fonts configuration: /var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_fonts.SJfGP8
[        ] test 0: Starting flutter_tester process with command=[/Users/lucassaudon/development/flutter/bin/cache/artifacts/engine/darwin-x64/flutter_tester, --disable-vm-service, --enable-checked-mode, --verify-entry-points, --enable-software-rendering, --skia-deterministic-rendering, --enable-dart-profiling, --non-interactive, --use-test-fonts, --disable-asset-fonts, --packages=/Users/lucassaudon/work/my_trash_app/.dart_tool/package_config.json, --flutter-assets-dir=/Users/lucassaudon/work/my_trash_app/build/unit_test_assets, /var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_listener.dt6gWC/listener.dart.dill], environment={FLUTTER_TEST: true, FONTCONFIG_FILE: /var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_fonts.SJfGP8/fonts.conf, SERVER_PORT: 60387, APP_NAME: my_trash_app, UNIT_TEST_ASSETS: /Users/lucassaudon/work/my_trash_app/build/unit_test_assets}
[   +3 ms] test 0: Started flutter_tester process at pid 28313
[ +321 ms] test 0: connected to test device, now awaiting test result
[        ] test 0: Waiting for test harness or tests to finish

00:00 +0: Given a long string, when rendered, then it meets accessibility guidelines                                                                                                                   
00:01 +0: Given a long string, when rendered, then it meets accessibility guidelines                                                                                                                   
00:01 +0: Given a long string, when rendered, then it meets accessibility guidelines                                                                                                                   
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: Tappable objects should be at least Size(48.0, 48.0)
  Actual: <Instance of 'WidgetTester'>
   Which: SemanticsNode#7(Rect.fromLTRB(0.0, 0.0, 382.0, 47.9), tags: [RenderViewport.twoPane],
actions: [focus, tap], flags: [isFocusable], label: "ABCDEFGHIJKLMNOPQRS", textDirection: ltr,
indexInParent: 0): expected tap target size of at least Size(48.0, 48.0), but found Size(382.0,
47.9)
          See also: https://support.google.com/accessibility/android/answer/7101858?hl=en

When the exception was thrown, this was the stack:
#0      fail (package:matcher/src/expect/expect.dart:149:31)
#1      _expect.<anonymous closure> (package:matcher/src/expect/expect.dart:125:9)
<asynchronous suspension>
<asynchronous suspension>
#8      expectLater.<anonymous closure> (package:flutter_test/src/widget_tester.dart:518:24)
<asynchronous suspension>
#9      _testAccessibility (file:///Users/lucassaudon/work/my_trash_app/test/widget_test.dart:71:3)
<asynchronous suspension>
#10     main.<anonymous closure> (file:///Users/lucassaudon/work/my_trash_app/test/widget_test.dart:9:5)
<asynchronous suspension>
#11     testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:189:15)
<asynchronous suspension>
#12     TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1032:5)
<asynchronous suspension>
<asynchronous suspension>
(elided 7 frames from dart:async and package:stack_trace)

The test description was:
  Given a long string, when rendered, then it meets accessibility guidelines
════════════════════════════════════════════════════════════════════════════════════════════════════

00:01 +0 -1: Given a long string, when rendered, then it meets accessibility guidelines [E]                                                                                                            
  Test failed. See exception logs above.
  The test description was: Given a long string, when rendered, then it meets accessibility guidelines
  

To run this test again: /Users/lucassaudon/development/flutter/bin/cache/dart-sdk/bin/dart test /Users/lucassaudon/work/my_trash_app/test/widget_test.dart -p vm --plain-name 'Given a long string, when rendered, then it meets accessibility guidelines'

00:01 +0 -1: Given a slightly shorter string, when rendered, then it meets accessibility guidelines                                                                                                    
00:01 +1 -1: Given a slightly shorter string, when rendered, then it meets accessibility guidelines                                                                                                    [ +368 ms] test 0: Test harness is no longer needed by test process
[        ] test 0: finished
[        ] test 0: cleaning up...
[        ] test 0: ensuring test device is terminated.
[        ] test 0: Terminating flutter_tester process
[        ] test 0: Shutting down DevTools server
[        ] test 0: Test process is no longer needed by test harness
[        ] test 0: Shutting down test harness socket server
[   +4 ms] test 0: flutter_tester process at pid 28313 exited with code=-9
[        ] test 0: deleting temporary directory
[   +1 ms] test 0: finished

00:01 +1 -1: Some tests failed.                                                                                                                                                                        
[   +2 ms] Deleting /var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_compiler.6WuDJf...
[        ] killing pid 28312
[   +7 ms] Deleting /var/folders/pw/qvzl_yx57vb_7kry7xhg_sd00000gn/T/flutter_tools.9rmj0A/flutter_test_fonts.SJfGP8...
[   +1 ms] test package returned with exit code 1
[        ] Runtime for phase TestRunner: Wall-clock: 0:00:01.265151; combined: 0:00:01.265165.
[        ] Runtime for phase Compile: Wall-clock: 0:00:00.462505; combined: 0:00:00.462523.
[        ] Runtime for phase Run: Wall-clock: 0:00:00.697354; combined: 0:00:00.697355.
[        ] Runtime for phase CoverageTotal: Wall-clock: 0:00:00.000000; combined: 0:00:00.000000.
[        ] Runtime for phase CoverageCollect: Wall-clock: 0:00:00.000000; combined: 0:00:00.000000.
[        ] Runtime for phase CoverageParseJson: Wall-clock: 0:00:00.000000; combined: 0:00:00.000000.
[        ] Runtime for phase CoverageAddHitmap: Wall-clock: 0:00:00.000000; combined: 0:00:00.000000.
[        ] Runtime for phase CoverageDataCollect: Wall-clock: 0:00:00.000000; combined: 0:00:00.000000.
[        ] Runtime for phase WatcherFinishedTest: Wall-clock: 0:00:00.000319; combined: 0:00:00.000319.
[   +3 ms] "flutter test" took 1 496ms.
[   +1 ms] Running 2 shutdown hooks
[        ] Shutdown hooks complete
[  +73 ms] exiting with code 1

```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0.1 24A348 darwin-arm64, locale fr-FR)
    • Flutter version 3.24.3 on channel stable at /Users/someone/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/someone/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] VS Code (version 1.94.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0

[✓] Connected device (1 available)
    • iPhone 16 Pro Max (mobile)      • C6A1D082-C349-401A-8B11-5033AB29E450 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>