Skip to content

Dialog actions do not respect Directionality #166880

Description

@galacticgibbon

Steps to reproduce

Open an AlertDialog.adaptive() with two or more actions in RTL language

Expected results

The buttons should be mirrored on right to left languages

Actual results

The actions are not mirrored

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class AlertDialogRTLPlayground extends ConsumerStatefulWidget {
  const AlertDialogRTLPlayground({super.key});

  @override
  ConsumerState<AlertDialogRTLPlayground> createState() =>
      _AlertDialogRTLPlaygroundState();
}

class _AlertDialogRTLPlaygroundState
    extends ConsumerState<AlertDialogRTLPlayground> {
  bool _isRTL = false;

  void _showAlertDialog(BuildContext context) {
    showDialog(
      context: context,
      builder:
          (context) => AlertDialog.adaptive(
            title: const Text('Alert Dialog'),
            content: const Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Text('This is a test alert dialog'),
                SizedBox(height: 8),
                Text('It should respect RTL direction'),
                SizedBox(height: 8),
                Text('But it doesn\'t properly align in RTL'),
              ],
            ),
            actions: [
              TextButton(
                onPressed: () => Navigator.pop(context),
                child: const Text('Cancel'),
              ),
              TextButton(
                onPressed: () => Navigator.pop(context),
                child: const Text('OK'),
              ),
            ],
          ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      locale: _isRTL ? const Locale('ur') : const Locale('en'),
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: const [Locale('en'), Locale('ur')],
      home: Builder(
        builder: (context) {
          return Scaffold(
            appBar: AppBar(
              title: const Text('AlertDialog RTL Test'),
              actions: [
                IconButton(
                  icon: const Icon(Icons.language),
                  onPressed: () {
                    setState(() {
                      _isRTL = !_isRTL;
                    });
                  },
                ),
              ],
            ),
            body: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    'Current Language: ${_isRTL ? 'Urdu (RTL)' : 'English (LTR)'}',
                    style: Theme.of(context).textTheme.titleLarge,
                  ),
                  const SizedBox(height: 20),
                  ElevatedButton(
                    onPressed: () => _showAlertDialog(context),
                    child: const Text('Show Alert Dialog'),
                  ),
                ],
              ),
            ),
          );
        },
      ),
    );
  }
}

Screenshots or Video

No response

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.1, on macOS 15.3.2 24D81 darwin-arm64, locale en-GB) [2.8s]
    • Flutter version 3.29.1 on channel stable at 
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 09de023485 (6 weeks ago), 2025-02-28 13:44:05 -0800
    • Engine revision 871f65ac1b
    • Dart version 3.7.0
    • DevTools version 2.42.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [2.8s]
    • Android SDK at /Users/Library/Android/sdk
    • Platform android-35, build-tools 34.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 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [2.6s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [9ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1) [9ms]
    • 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 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.99.0) [8ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.100.0

[✓] Network resources [624ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)found in release: 3.29Found to occur in 3.29found in release: 3.31Found to occur in 3.31frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions