使用 easy_localization 包进行 flutter 本地化时出现文本溢出

问题描述 投票:0回答:1

我做了一个颤动的应用程序。我为此应用程序添加了语言支持(本地化)。我为此使用了 easy_localization 包。土耳其语 英语 法语 德语 阿塞拜疆语 格鲁吉亚语 阿拉伯语 土耳其阿拉伯语 俄语 俄语、英语 法语 乌兹别克语和蒙古语 我提供了语言支持,但当我更改文本中的语言时,会发生文本溢出。有什么解决方法吗?如果有,这些是什么?

我添加了语言支持,结果导致文本溢出

enter code here[![enter image description here][1]][1]
                          DebouncedButton(
                            onTap: () => Navigator.of(context).push(MaterialPageRoute(
                              builder: (context) => const PriceAlarmList(isPrice: true),
                            )),
                            child: Container(
                              width: screenSize.width / 3.393,
                              height: screenSize.width / 3.393,
                              padding: EdgeInsets.only(top: screenSize.height / 42.666),
                              decoration: ShapeDecoration(
                                color: MarasColor.onSecondaryColor,
                                shape: RoundedRectangleBorder(
                                  borderRadius: BorderRadius.circular((screenSize.width / 3.393) / 5.809),
                                ),
                              ),
                              child: Column(
                                children: [
                                  Container(
                                    width: screenSize.width / 6.9,
                                    height: screenSize.width / 6.9,
                                    decoration: ShapeDecoration(
                                      color: MarasColor.bgColor,
                                      shape: const CircleBorder(),
                                    ),
                                    alignment: Alignment.center,
                                    child: SvgPicture.asset("assets/maras/svg/price-alarm-grey.svg"),
                                  ),
                                  SizedBox(
                                    height: screenSize.height / 49.777,
                                  ),
                                  CustomText(
                                    data: 'profile.my_price_alert_list'.tr(),
                                    height: 1.181,
                                    color: MarasColor.txtColor,
                                    weight: FontWeight.w500,
                                    size: 11,
                                  )
                                ],
                              ),
                            ),
                          ),

示例图像 [1]:https://i.stack.imgur.com/pKJ4z.jpg

flutter dart text localization overflow
1个回答
0
投票

确定卡片的高度。

如果您想要卡片的动态高度,请使用

Expaned

Expanded(
  child: Text(
    'profile.my_price_alert_list'.tr(),
     style: TextStyle(
       color: MarasColor.txtColor,
       fontWeight: FontWeight.w500,
       fontSize: 11,
     ),
  ),
)

否则使用此属性:

Text(
  'profile.my_price_alert_list'.tr(),
   style: TextStyle(
     color: MarasColor.txtColor,
     fontWeight: FontWeight.w500,
     fontSize: 11,
   ),
   maxLines: 1, // Set maximum number of lines
   overflow: TextOverflow.ellipsis, // Add ellipsis if text overflows
)
© www.soinside.com 2019 - 2024. All rights reserved.