Directionality( textDirection: TextDirection.rtl, ) 在颤动中不起作用

时间:2021-04-18 12:23:05

标签: flutter user-interface dart widget

在我的应用程序中,我在前 4 页中使用了 rtl 方向,它工作正常,但在添加 BottomNavigationBar 及其小部件后,小部件不会响应任何方向或任何列效果

这是我的BottomNavigationBar代码

bottomNavigationBar: BottomAppBar(
          shape: CircularNotchedRectangle(),
          child: Container(
            // height: MediaQuery.of(context).size.height * .1,
            child: BottomNavigationBar(
              type: BottomNavigationBarType.fixed,
              selectedItemColor: Colors.orange,
              selectedFontSize: 0,
              unselectedFontSize: 0,
              showSelectedLabels: false,
              showUnselectedLabels: false,
              //iconSize: 22,
              elevation: 0,
              backgroundColor: Colors.transparent,
              // selectedIconTheme: IconThemeData(
              //   color: Colors.orange,
              // ),
              // unselectedItemColor: Colors.grey,
              currentIndex: widget.currentTab,
              onTap: (int i) {
                print(i);
                this._selectTab(i);
              },
              // this will be set when a new tab is tapped
              items: [
                BottomNavigationBarItem(
                  icon: Container(
                    margin: EdgeInsets.all(0),
                    padding: EdgeInsets.only(left: 20),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        new Image.asset(
                          "assets/images/home.png",
                          height: 20,
                          width: 20,
                          fit: BoxFit.contain,
                          color: Colors.grey,
                        ),
                        Text(
                          'الرئيسية',
                          style: TextStyle(color: Colors.grey, fontSize: 10),
                        )
                      ],
                    ),
                  ),
                  activeIcon: Container(
                    margin: EdgeInsets.all(0),
                    padding: EdgeInsets.only(left: 20),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        new Image.asset(
                          "assets/images/home.png",
                          height: 20,
                          width: 20,
                          fit: BoxFit.contain,
                          color: Color.fromRGBO(255, 187, 17, 1),
                        ),
                        Text(
                          'الرئيسية',
                          style: TextStyle(
                              color: Color.fromRGBO(255, 187, 17, 1),
                              fontSize: 12),
                        )
                      ],
                    ),
                  ),
                  label: '',
                ),
              ],
            ),
          ),
        ),

以及第一页的代码

Directionality(
      textDirection: TextDirection.rtl,
      child: Scaffold(
        //backgroundColor: Colors.white,
        //resizeToAvoidBottomInset: false,
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            // mainAxisAlignment: MainAxisAlignment.end,
            // crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Expanded(
                  child: Column(
                children: [
                  SizedBox(
                    height: MediaQuery.of(context).size.height * .05,
                  ),
                  Text(
                    ", أهلا محمود",
                    style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
                  ),
                  Text(
                    "اختر الخدمة المناسبة لك",
                    style: TextStyle(
                        fontSize: 14, color: Color.fromRGBO(138, 138, 138, 1)),
                  ),
                  SizedBox(
                    height: MediaQuery.of(context).size.height * .05,
                  ),
                ],
              ))
            ],
          ),
        ),
      ),
    );

所以任何人都知道这个问题!!!

2 个答案:

答案 0 :(得分:1)

尝试使用 flutter_localizations

将此添加到您的发布规范:

  flutter_localizations:
    sdk: flutter

然后在您的主文件中将它们添加到您的 MaterialApp 小部件

localizationsDelegates: [
        GlobalCupertinoLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      supportedLocales: [
        Locale("ar", "YE"), // OR Locale('ar', 'AE') OR Other RTL locales
      ],

答案 1 :(得分:0)

清洁并重新安装应用程序后小部件可以正常工作,谢谢