首页 > 解决方案 > iOS Flutter-如何调整字符串表情符号的大小?

问题描述

在 Android 设备上运行时,我的应用程序在下面将显示的示例中没有出现对齐问题。当我想在我的 iOS 设备上运行它时,我遇到了以下对齐问题。

有问题的对齐从这里开始。 当我选择波斯语或阿拉伯语时,我的应用程序经历了完全对称的变化,并且一些表情符号正确对齐,而另一些则显得扭曲。

在此处输入图像描述

有问题的对齐从这里开始。当我选择波斯语或阿拉伯语时,我的应用程序经历了完全对称的变化,并且一些表情符号正确对齐,而另一些则显得扭曲。

我的代码:

Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    backgroundColor: ortaMavi,
    leading: IconButton(
        onPressed: () {
          Navigator.of(context).pop();
        },
        icon: Icon(
          Icons.arrow_back_ios,
          size: 20,
          color: Colors.white,
        )),
    title: Center(child: Text(titleHolder)),
    actions: <Widget>[
      Center(
        child: Container(
            margin: EdgeInsets.all(15),
            child: Text(
              flagHolder,
              style: TextStyle(fontSize: 25),
            )),
      )
    ],
  ),
  body: SafeArea(
    child: ListView.builder(
        padding: const EdgeInsets.symmetric(vertical: 5),
        itemCount: countries.length,
        itemBuilder: (BuildContext context, int index) {
          return GestureDetector(
            onTap: () {
              EasyLocalizationProvider.of(context)
                  .data
                  .changeLocale(langs[index]);
              setState(() {
                titleHolder = countries[index];
                flagHolder = flags[index];
                selectedLangIndex = index;
              });
            },
            child: Container(
              decoration: BoxDecoration(
                color:
                    selectedLangIndex != null && selectedLangIndex == index
                        ? ortaMavi.withOpacity(0.2)
                        : Colors.white,
                boxShadow: [
                  BoxShadow(
                    color: Colors.lightBlueAccent.withOpacity(0.5),
                    spreadRadius: 2,
                    blurRadius: 3,
                    offset: Offset(0, 3), // changes position of shadow
                  ),
                ],
              ),
              height: 50,
              child: Padding(
                padding: EdgeInsets.symmetric(horizontal: 15),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    Text(
                      '${countries[index]}',
                      style: TextStyle(
                          fontSize: 20,
                          color: selectedLangIndex != null &&
                                  selectedLangIndex == index
                              ? Colors.white
                              : Colors.black),
                    ),
                    Text(
                      flags[index],
                      style: TextStyle(fontSize: 25),
                    )
                  ],
                ),
              ),
            ),
          );
        }),
  ),
);

}

标签: iosflutteralignment

解决方案


您可以将标志字符串放入 SizedBox

SizedBox(
  width: 200.0,
  height: 200.0,
  child:Text(
        flags[index],
    ),
)

推荐阅读