Skip to content

ExpansionTile : expandedAlignment not accepts AlignmentDirectional to support rtl language #180813

Open

Description

@devnoaman

the expandedAlignment defined as Alignment , not as AlignmentGeometry even if _buildBody returns Align widget which accepts alignment property as AlignmentGeometry

Activity

  1. added
    c: new featureNothing broken; request for a new capability
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    c: proposalA detailed proposal for a change to Flutter
    team-designOwned by Design Languages team
    in triagePresently being triaged by the triage team
    and removed
    in triagePresently being triaged by the triage team
    on Jan 12, 2026
  2. victorsanni commented on Jan 12, 2026

    @victorsanni
    Contributor

    What about using AlignmentGeometry.resolve with rtl to get the alignment and pass it into expandedAlignment?

  3. devnoaman commented on Jan 13, 2026

    @devnoaman
    ContributorAuthor

    @victorsanni we can do that with one trade-off , The .resolve() method is not context-aware on its own. so this shifts the burden of finding the text direction from the Framework to the developer , so the developer forced to perform a lookup first to find out if the app is currently LTR or RTL.

    by using the Automatic Lookup (i.e expandedAlignment: AlignmentDirectional. ) , we writing clean and simple without creating a boilerplate or doing manual look up .

    find examples below

    manual look up

    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter ExpansionTile Test',
          localizationsDelegates: const [
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,
          ],
          locale: Locale('ar'),
    
          supportedLocales: const [Locale('en', 'US'), Locale('ar', 'IQ')],
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
          ),
          home: const MyHomePage(),
        );
      }
    }
    
    class MyHomePage extends StatelessWidget {
      const MyHomePage({super.key});
    
      @override
      Widget build(BuildContext context) {
        // 1- we need lookup the framework and get the current TextDirection first
        final TextDirection currentDirection = Directionality.of(context);
        // 2- pass the TextDirection to the resolve method
        final Alignment resolvedAlignment = AlignmentDirectional.centerStart
            .resolve(currentDirection);
        return Scaffold(
          body: Center(
            child: ExpansionTile(
              title: Text('data'),
              expandedAlignment: resolvedAlignment,
              children: [Text('data')],
            ),
          ),
        );
      }
    }
    

    automatic look up

    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter ExpansionTile Test',
          localizationsDelegates: const [
            GlobalMaterialLocalizations.delegate,
            GlobalWidgetsLocalizations.delegate,
            GlobalCupertinoLocalizations.delegate,
          ],
          locale: Locale('ar'),
    
          supportedLocales: const [Locale('en', 'US'), Locale('ar', 'IQ')],
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
          ),
          home: const MyHomePage(),
        );
      }
    }
    
    class MyHomePage extends StatelessWidget {
      const MyHomePage({super.key});
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: ExpansionTile(
              title: Text('data'),
              // the Framwork handles the lookup automatically
              expandedAlignment: AlignmentDirectional.centerStart,
              children: [Text('data')],
            ),
          ),
        );
      }
    }
    
    
    
  4. added
    P3Issues that are less important to the Flutter project
    triaged-designTriaged by Design Languages team
    on Jan 14, 2026
  5. dkwingsmt commented on Jan 14, 2026

    @dkwingsmt
    Contributor

    To confirm, are you suggesting a new property that takes into account text direction? Should it replace the current one? (from triage)

  6. devnoaman commented on Jan 15, 2026

    @devnoaman
    ContributorAuthor

    @dkwingsmt thanks for your review

    We are not introducing a new property. Instead, we are generalizing the existing expandedAlignment property by changing its type from Alignment to AlignmentGeometry.

    Since AlignmentGeometry is the base class for both, this change is non-breaking:

    • Backward Compatible: Alignment inherits from AlignmentGeometry, so existing code remains valid.

    • New Feature: AlignmentDirectional also inherits from AlignmentGeometry, allowing us to support RTL layouts naturally.

  7. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 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

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: material_uimaterial_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