简体   繁体   中英

why Text Alignment doesn't work in flutter?

I create an application that in some parts has Persian language and They are not on the same level like image below:

在此处输入图像描述

But for English language work correctly like image below:

在此处输入图像描述

Here is my code:

body: Container(
        child: ReorderableListView(
          onReorder: (oldIndex, newIndex) {
            setState(() {
              _updateItems(oldIndex, newIndex);
            });
          },
          children: [
            for (final item in data)
              Card(
                key: ValueKey(item),
                color: Colors.grey,
                child: Container(
                  padding: const EdgeInsets.only(left: 10, right: 10),
                  child: CheckboxListTile(
                    controlAffinity: ListTileControlAffinity.leading,
                    value: true,
                    onChanged: (bool value) {
                      setState(() {
                        value = !value;
                      });
                    },
                    title: Align(
                      alignment: Alignment.centerRight,
                      child: Text(
                        '$item',
                        style: TextStyle(
                          color: Colors.white,
                        ),
                      ),
                    ),
                  ),
                ),
              ),
          ],
        ),
      ),

Please help me, thanks.

Be sure there is no space on start of your text and make textDirection rtl;

Text(
  '${item.trim()}',
  textDirection: TextDirection.rtl,
  style: TextStyle(
    color: Colors.white,
  ),
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM