Search code examples
flutterright-to-leftdrawer

flutter put drawer content right to left


Dear Flutter developers

How to put my drawer content from right to left including the account information.the picture is included for result and you can see the texts are in left side, but I want to put them in right side or in center at least. Thanks

my code is as bellow :

  endDrawer: Drawer(

          child: new Column(
              textDirection: TextDirection.rtl,

              children: <Widget> [
                Padding(
                  padding:
                  const EdgeInsets.only(top: 22.0, left: 42.0, right: 42.0),

                ),
                new UserAccountsDrawerHeader(

                  currentAccountPicture: new CircleAvatar (

                    backgroundColor: Colors.blue,
                    child: Image.asset("assets/img/logo.png"),

                  ),

                  accountName: Text("عنوان",style: TextStyle(
                    fontFamily: "Bahij",
                    fontSize: 14,
                  ),textAlign: TextAlign.center,),
                  accountEmail:

                  Text("ایمیل آدرس[![enter image description here][1]][1]" ,style: TextStyle(
                    fontFamily: "Bahij",
                    fontSize: 14,
                  ),textAlign: TextAlign.center,textDirection: TextDirection.rtl),


                )
              ]
          )
      ),


Solution

  • if you want to localization your app you should write your MaterialApp widget like this :

    MaterialApp(
            debugShowCheckedModeBanner: false,
            title: 'my app',
            localizationsDelegates: [
              GlobalMaterialLocalizations.delegate,
              GlobalWidgetsLocalizations.delegate,
            ],
            supportedLocales: [
              Locale(
                  "languageCode", "countryCode"
              ),
            ],
            locale: Locale(
                "languageCode", "countryCode"
            ),
            theme: mainThemeData,
            home: AppSplash(),
          )
    

    change countryCode and languageCode with your language and country code