Flutter container to position bottom right

3.3k views Asked by At

I have a flutter container (Trending text in violet) which is positioned top left right now. I am wondering what code changes i should do to position the container bottom right ?

                     Container(
                        height: 25.0,
                        width: MediaQuery.of(context).size.width * 0.25,
                        margin: const EdgeInsets.all(8.0),
                        decoration: BoxDecoration(
                          color: Theme.of(context).primaryColor,
                          borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(12.0),
                            bottomRight: Radius.circular(12.0),
                          ),
                        ),
                        alignment: Alignment.center,
                        child: Shimmer.fromColors(
                          baseColor: Colors.white60,
                          highlightColor: Colors.white,
                          period: Duration(milliseconds: 1000),
                          child: Text(
                            'Trending',
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: GoogleFonts.poppins(
                              color: Colors.white.withOpacity(0.9),
                              fontSize: 13.0,
                              fontWeight: FontWeight.w500,
                            ),
                          ),
                        ),
                      )

Current view

enter image description here

2

There are 2 answers

2
Gaspard Merten On BEST ANSWER

The first thing is that you would need to adapt your border radius for the right size (invert them).

The second one is that you should modify the Stack widget above this Container and set its alignment property to Alignment. topRight !

0
Andrej On

Wrap your image and text in a Stack and set the wanted alignment.

Stack(
alignment: Alignment.topRight,
children: <Widget>[
 ...
 ],
)