Skip to content

[cupertino_ui] CupertinoActionSheet semantics label is hardcoded to 'Alert' instead of using CupertinoLocalizations.alertDialogLabel #195019

Closed
flutter/packages
#13377

Description

@alexandrembsb

What package does this bug report belong to?

cupertino_ui

What target platforms are you seeing this bug on?

iOS

Have you already upgraded your packages?

No

Dependency versions

  cupertino_ui:
    dependency: "direct main"
    description:
      name: cupertino_ui
      sha256: c23816577a1280cff409e989541767887011f8f1d8c1863a794ed308af46f2a9
      url: "https://pub.dev"
    source: hosted
    version: "1.1.1"

The same literal is still present in 1.1.4 (lib/src/dialog.dart, the Semantics wrapping the action sheet).

Steps to reproduce

  1. Create an app with locale: Locale('pt') and GlobalCupertinoLocalizations.delegates.
  2. Open a CupertinoActionSheet with showCupertinoModalPopup.
  3. Inspect the semantics tree (or open the sheet with VoiceOver on iOS).

Expected results

The node that names the route uses the localized label, like CupertinoAlertDialog already does (localizations.alertDialogLabel). For pt that is "Alerta".

Actual results

The node has label: "Alert", role: dialog, scopesRoute and namesRoute regardless of the locale. The value is a string literal in lib/src/dialog.dart:

child: Semantics(
  namesRoute: true,
  scopesRoute: true,
  explicitChildNodes: true,
  role: SemanticsRole.dialog,
  label: 'Alert',

CupertinoAlertDialog in the same file uses localizations.alertDialogLabel, and the ARB files already translate that key (e.g. cupertino_pt.arb: "alertDialogLabel": "Alerta"). Since the label is on the node that names the route, apps can't override it from outside, so localized apps get "Alert" announced in English.

Suggested fix:

label: CupertinoLocalizations.of(context).alertDialogLabel,

Code sample

Code sample

A widget test that reproduces it (only cupertino_ui and flutter_test):

import 'package:cupertino_ui/cupertino_ui.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('action sheet route label follows the locale', (tester) async {
    final handle = tester.ensureSemantics();
    await tester.pumpWidget(
      CupertinoApp(
        locale: const Locale('pt'),
        localizationsDelegates: GlobalCupertinoLocalizations.delegates,
        supportedLocales: const [Locale('pt')],
        home: Builder(
          builder: (context) => CupertinoButton(
            child: const Text('open'),
            onPressed: () => showCupertinoModalPopup<void>(
              context: context,
              builder: (_) => CupertinoActionSheet(
                title: const Text('Tema'),
                actions: [
                  CupertinoActionSheetAction(
                    onPressed: () {},
                    child: const Text('Claro'),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
    await tester.tap(find.text('open'));
    await tester.pumpAndSettle();

    // Passes: the localization exists.
    expect(
      CupertinoLocalizations.of(tester.element(find.text('Claro'))).alertDialogLabel,
      'Alerta',
    );
    // Passes today: the hardcoded label is used.
    expect(find.bySemanticsLabel('Alert'), findsOneWidget);
    // Fails today: expected after the fix.
    expect(find.bySemanticsLabel('Alerta'), findsOneWidget);
    handle.dispose();
  });
}

Screenshots or Videos

N/A: the problem is in the semantics tree, not in the rendered pixels.

Logs

Logs
Expected: exactly one matching candidate
  Actual: _ElementPredicateWidgetFinder:<Found 0 widgets with a semantics label named "Alerta": []>
   Which: means none were found but one was expected

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.47.2, on Debian GNU/Linux forky/sid 7.2.11+deb14-amd64, locale pt_BR.UTF-8)
    • Flutter version 3.47.2 on channel stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d3b14c8769 (8 weeks ago), 2026-08-26 16:07:51 -0700
    • Engine revision a804b26164
    • Dart version 3.13.2
    • DevTools version 2.60.0

[!] Android toolchain - develop for Android devices (Android SDK version 37.0.0)
    • Platform android-37.2, build-tools 37.0.0
    • Java version OpenJDK Runtime Environment (build 25.0.3+-15898627-b508.16)
    ✗ Android license status unknown.

[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Connected device (2 available)
[✓] Network resources

The bug is in Dart code and reproduces in flutter test; no Mac/iOS toolchain is involved.

Activity

  1. suryaKommana2662 commented on Oct 22, 2026

    @suryaKommana2662
    Contributor

    @alexandrembsb Thanks for the report and reproduction test. I reproduced the issue locally. The test passes when expecting the hardcoded "Alert" semantics label but fails when expecting the localized "Alerta" label. Routing this to the accessibility team for further investigation.

    ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
    The following TestFailure was thrown running a test:
    Expected: exactly one matching candidate
      Actual: _ElementPredicateWidgetFinder:<Found 0 widgets with a semantics label named "Alerta": []>
       Which: means none were found but one was expected
    
    When the exception was thrown, this was the stack:
    #4      main.<anonymous closure> (file:///Users/suryakommana/StudioProjects/counterapp/test/widget_test.dart:42:5)
    <asynchronous suspension>
    #5      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:192:15)
    <asynchronous suspension>
    #6      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:2064:5)
    <asynchronous suspension>
    <asynchronous suspension>
    (elided one frame from package:stack_trace)
    
    This was caught by the test expectation on the following line:
      file:///Users/suryakommana/StudioProjects/counterapp/test/widget_test.dart line 42
    The test description was:
      action sheet route label follows the locale
    ════════════════════════════════════════════════════════════════════════════════════════════════════
    00:01 +0 -1: action sheet route label follows the locale [E]                                                                                                          
      Test failed. See exception logs above.
      The test description was: action sheet route label follows the locale
      
    
    To run this test again: /Users/suryakommana/develop/flutter/bin/cache/dart-sdk/bin/dart test /Users/suryakommana/StudioProjects/counterapp/test/widget_test.dart -p vm --plain-name 'action sheet route label follows the locale'
    00:01 +0 -1: Some tests failed.   

    Flutter Doctor Output

    [✓] Flutter (Channel master, 3.50.0-1.0.pre-185, on macOS 27.0 26A428 darwin-arm64, locale en-IN) [1,074ms]
        • Flutter version 3.50.0-1.0.pre-185 on channel master at /Users/suryakommana/develop/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 84abdf7372 (5 hours ago), 2026-10-22 05:46:25 +0000
        • Engine revision 84abdf7372
        • Dart version 3.15.0 (build 3.15.0-62.0.dev)
        • DevTools version 2.61.0
        • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
          enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration, enable-riscv64, enable-hcpp
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,275ms]
        • Android SDK at /Users/suryakommana/Library/Android/sdk
        • Emulator version 37.1.11.0 (build_id 15917651) (CL:N/A)
        • Platform android-37.0, build-tools 36.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 25.0.2+-15348964-b329.117)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 27.1) [560ms]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 27A9275
        • CocoaPods version 1.17.0
    
    [✓] Chrome - develop for the web [7ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Connected device (4 available) [6.0s]
        • sdk gphone16k arm64 (mobile) • emulator-5554                        • android-arm64  • Android 17 (API 37) (emulator)
        • iPhone 18 Pro (mobile)       • D80F2104-E911-4251-BEDD-E67D9B7EBF58 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-27-0 (simulator)
        • macOS (desktop)              • macos                                • darwin-arm64   • macOS 27.0 26A428 darwin-arm64
        • Chrome (web)                 • chrome                               • web-javascript • Google Chrome 155.0.8059.85
    
    [✓] Network resources [566ms]
        • All expected network resources are available.
    
    • No issues found!
  2. added
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    p: cupertino_uicupertino_ui package in flutter/packages
    packageflutter/packages repository. See also p: labels.
    fyi-designFor the attention of Design Languages team
    team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    a: tests"flutter test", flutter_test, or one of our tests
    and removed
    in triagePresently being triaged by the triage team
    on Oct 22, 2026
  3. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on Oct 27, 2026
  4. added
    team-designOwned by Design Languages team
    triaged-designTriaged by Design Languages team
    and removed
    team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: tests"flutter test", flutter_test, or one of our testshas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cupertino_uicupertino_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions