How to make AutoSizeText scale with font and two-line?

Issue

I am using AutoSizeText package from https://pub.dev/packages/auto_size_text.

I try to make text scalable and two-line but properties like maxLines does not working and font is not scaling with possible space.

               Container(
                    padding: EdgeInsets.symmetric(horizontal: size.width * 0.06) +
                        EdgeInsets.only(top: size.height * 0.022),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        FlutterSwitch(
                          onToggle: (val) {
                            setState(() {
                              // some code....
                            });
                          },
                          value: someBoolean
                        ),
                        AutoSizeText(
                          'Some long text that is not scaling with possible space?',
                           style: TextStyle(
                              fontSize: 12
                           ),
                           minFontSize: 6,
                           maxLines: 2,
                        ),
                      ],
                    ),
                  ),

enter image description here

I tried to wrap AutoSizeText with Container or SizedBox with given height but it is also not working.

How can I fix this?

Solution

Two Way :

  Expanded(
             child:
            AutoSizeText(
                                      'Some long text that is not scaling with possible space?',
                                       style: TextStyle(
                                          fontSize: 12
                                       ),
                                       minFontSize: 6,
                                       maxLines: 2,
                                    ),
            )

OR

 AutoSizeText(
                                  'Some long text that is not scaling with possible space?',
                                   style: TextStyle(
                                      fontSize: 12
                                   ),
                                   minFontSize: 6,
                                   maxLines: 2,
        overflow: TextOverflow.ellipsis,
                                ),

Answered By – Anmol Mishra

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.