luc
luc

Reputation: 1519

Flutter: How make container fit to its child

I am using container with Text widget inside, I want container to fit the text widget, not to expand to maximum. If you know how can I do that pls tell me.

This is my code:

Container(
                      height: MediaQuery.of(context).size.height * 0.07,
                      decoration: BoxDecoration(
                          border: Border.all(color: Colors.grey, width: 1),
                          borderRadius:
                              BorderRadius.all(Radius.circular(2.0))),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Padding(
                            padding: const EdgeInsets.only(left: 10),
                            child: widgets[index],
                          ),
                          IconButton(
                              icon: Icon(
                                Icons.close,
                                size: 20,
                                color: Colors.grey,
                              ),
                              onPressed: () => {
                                    setState(() {
                                      widgets.remove(widgets[index]);
                                    }),
                                  })
                        ],
                      ),
                    );

Upvotes: 0

Views: 240

Answers (1)

Nassar
Nassar

Reputation: 100

Try this for the row

mainAxisSize: MainAxisSize.min

Upvotes: 1

Related Questions