Ask Your Question
4

What is the method for adding an icon to the lower right corner of a container in Flutter?

asked 2021-10-31 11:00:00 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-07-14 03:00:00 +0000

nofretete gravatar image

One possible method to add an icon to the lower right corner of a container in Flutter is to create a Stack widget and position the container and the icon at specific positions within the stack. Here's an example code snippet:

Stack(
  children: [
    Container(
      width: 200,
      height: 200,
      color: Colors.blue,
      child: Text("Container"),
    ),
    Positioned(
      bottom: 0,
      right: 0,
      child: Icon(Icons.favorite, color: Colors.red),
    ),
  ],
)

In this example, we create a blue container with a size of 200x200 and a text label. We wrap the container and the icon in a Stack widget, and position the icon at the bottom-right corner using the bottom and right properties of the Positioned widget. We also set the color of the icon to red using the color property.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-10-31 11:00:00 +0000

Seen: 10 times

Last updated: Jul 14 '22