1

how to change text direction to RTL in SearchDelegate

From the research, I found a way to change the color, but I did not find a way to change the direction of the text

thanks

class MySearchDelegte extends SearchDelegate {

  @override
  String get searchFieldLabel => 'ابحث حسب اسم المكتب';
  .....
  .....

  @override
  ThemeData appBarTheme(BuildContext context) {
    return Theme.of(context).copyWith(
      appBarTheme: Theme.of(context).appBarTheme.copyWith(
            color: const Color(0xff202c3b),

          ),
    );
  }
}
tomerpacific
  • 4,704
  • 13
  • 34
  • 52
Khalid
  • 123
  • 1
  • 7
  • Does this answer your question? [right-to-left (RTL) in flutter](https://stackoverflow.com/questions/50535185/right-to-left-rtl-in-flutter) – tomerpacific Jan 26 '23 at 08:44

1 Answers1

0

You need to wrap the entire SearchDelegate widget in a Directionality widget and set the textDirection property to TextDirection.rtl.

Directionality(
  textDirection: TextDirection.rtl,
  child: MySearchDelegate(),
)

You can also set this property on an ancestor MaterialApp , which will propagate the text direction to all descendant widgets.

aterialApp(
  home: MySearchDelegate(),
  localizationsDelegates: [
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
  ],
  supportedLocales: [
    const Locale('ar', 'AE'), // Arabic
  ],
  locale: const Locale('ar', 'AE'),
)

Find more information in official flutter documentation

krishnaacharyaa
  • 14,953
  • 4
  • 49
  • 88
  • Thank you, but we can't warp SearchDelegate with any other widget And I tried to warp the scaffold with text direction, but it didn't work either – Khalid Feb 22 '23 at 18:06