Home > Enterprise >  How I can let text paragraph take 100% of the page in flutter
How I can let text paragraph take 100% of the page in flutter

Time:12-02

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%

CodePudding user response:

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
),),)

CodePudding user response:

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: () {},
                              ),
                            ),
  • Related