flutter AutosizeText不调整文本大小

ki1q1bka  于 2023-02-09  发布在  Flutter
关注(0)|答案(1)|浏览(228)

我试图创建一个自定义的listTile可以扩展,如果它有多行,并保持照片居中,但我的问题是AutosizeText不工作,如果我用扩展 Package AutosizeText出现错误。我可以使用listTile类,如果有一个方法知道是否是树线或没有你能帮我解决这个问题吗?
下面是我代码:

Card(
  elevation: 8,
  child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            children: [
              SizedBox(
                width: 70.0,
                height: 70.0,
                child: ClipRRect(
                  borderRadius: BorderRadius.circular(8),
                  child: Image.asset(
                    'assets/images/photo.jpg',
                    width: 70,
                    height: 70,
                    fit: BoxFit.cover,
                  ),
                ),
              ),
              SizedBox(
                width: 24,
              ),
              Column(
                children: [
                  AutoSizeText(
                        '{otherUser.name! otherUser.lastName!}',
                        maxLines: 1,
                        style: Theme.of(context).textTheme.bodyText1!),
                  
                 Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
         
         Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                Container(
                  margin: const EdgeInsets.symmetric(horizontal: 2),
                  child: Image(
                    image: AssetImage(
                        'assets/icons/icon2.png'),
                    height: 20,
                  ),
                ),
           
              AutoSizeText(
                    otherUser.country![0],
                    maxLines: 2,
                    style: Theme.of(context)
                        .textTheme
                        .subtitle2!
                        
                  
                ),
              ],
            ),
          
       Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  Container(
                    margin: const EdgeInsets.symmetric(horizontal: 2),
                    child: const FaIcon(
                      FontAwesomeIcons.locationDot,
                      size: 20,
                      color: Colors.black45,
                    ),
                  ),
               AutoSizeText(
                      otherUser.location!,
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,
                      style: Theme.of(context)
                          .textTheme
                          .subtitle2!
                       
                    ),
                  
                ]),
          
        ])
                ],
              ),
            ],
          ),
          Row(
            children: [Icon(Icons.star_half_outlined), Text("4.5")],
          )
        ],
      ),
),
wwwo4jvm

wwwo4jvm1#

这可能是由于AutoSizeText小工具中默认的最小和最大大小。请将minSize和maxSize参数更改为您需要的范围。
注:如果发现有帮助,请投赞成票并标记为正确答案,谢谢。

相关问题