skip to Main Content

I have pageView builder which each page contains different paragraph I want to let this paragraph take all the space in page without spaces to be in the same aligment.

I tried it by my my problem was that some paragraphs come with 7 lines which can take 100% of the page but some of them come with 3 lines and does not take remaining space takes only 30% from the page

Tried code:

 Expanded(
                              child: AutoSizeText.rich(
                                textAlign: index == 0 ? TextAlign.center : TextAlign.justify,
                                TextSpan(
                                  children: [
                                    for (var i = 1; i <= list.length; i++) ...{
                                      TextSpan(
                                        text: "${list[i - 1]} ",
                                        style: GoogleFonts.balooBhai2(
                                          fontSize: 25,
                                          color: Colors.black87,
                                        ),
                                      ),
                                    }
                                  ],
                                ),
                              ),
                            ),

Expected result:all texts on all pages is the same height

The result is: some texts take 50% of the page some it take 150% some it take 100%

2

Answers


  1. Chosen as BEST ANSWER

    I fixed the issue by this code

    Flexible(
                                  child: GestureDetector(
                                    child: AutoSizeText(
                                      list.join(" "),
                                      style: GoogleFonts.balooBhai2(
                                        fontSize: index == 0 ? 20 : 90,
                                        color: Colors.black87,
                                      ),
                                      textAlign: index == 0 ? TextAlign.center : TextAlign.justify,
                                    ),
                                    onTap: () {},
                                  ),
                                ),
    

  2. Try this:

    ConstrainedBox(
    constraints; BoxConctraints(
    maxHeight: MediaQuery.of(context).size.height,
    maxWidth: MediaQuery.of(context).size.width,
    child: FittedBox(
      child: yourWidget(), // replace it with your widget
    ),),)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search